我想按一个类别显示我在投资组合过滤器中的最后一个项目,我已经添加了显示我所有最新投资组合项目的代码,我只需要在我的投资组合类别中按类别 ID 过滤它。
<?php if (_sg('Home')->showLatestP()) { ?>
<?php
$args = array();
$args['post_type'] = 'portfolio';
$args['posts_per_page'] = 20;
$args['meta_key'] = '_thumbnail_id';
query_posts($args);
?>
<div class="divider"></div>
<?php if (have_posts()) { ?>
<div class="<?php _sg('Home')->eLatestPType(); ?>">
<?php $i = 0; ?>
<ul class="slides">
<?php while (have_posts()) : the_post(); $i++; ?>
<?php if ($i == 1 OR $i % 5 == 0) echo '<li><ul>'; ?>
<li class="col1-4<?php if ($i % 4 == 0) echo ' omega'; ?>">
<div class="proj-img<?php if (_sg('PortfolioPost', TRUE)->getType(get_the_ID()) == 'video') echo ' proj-video'; ?>">
<?php the_post_thumbnail('sg_portfolio4', array('alt' => get_the_title())); ?>
<?php if (_sg('Home')->getLatestPImgType() == 'large') { ?>
<?php $big = (_sg('PortfolioPost', TRUE)->getType(get_the_ID()) == 'video') ? _sg('PortfolioPost', TRUE)->getVideoUrl(get_the_ID()) : wp_get_attachment_url(get_post_thumbnail_id()); ?>
<a href="<?php echo $big; ?>" class="prettyPhoto zoom" title="<?php the_title(); ?>"></a>
<?php } else { ?>
<a href="<?php the_permalink(); ?>"></a>
<?php } ?>
</div>
<div class="proj-info"><h4><a class="enter-icn" href="<?php the_permalink(); ?>"><?php echo sg_text_trim(get_the_title(), 30); ?></a></h4>
<?php if (_sg('Home')->getLatestPText() == 'categories') { ?>
<p><?php echo sg_the_tag_list('portfolio_category', ', ', FALSE); ?></p>
<?php } else { ?>
<p><?php echo sg_text_trim(get_the_excerpt(), 30); ?></p>
<?php } ?>
</div>
</li>
<?php if ($i % 4 == 0) echo '</ul></li>'; ?>
<?php endwhile; ?>
<?php if ($i % 4 != 0) echo '</ul></li>'; ?>
</ul>
</div>
<?php } else {
$empty_extras = __('Portfolio is empty', SG_TDN);
echo sg_message($empty_extras);
} ?>
<?php } ?>
谢谢你的帮助。