我想在一个类别的投资组合过滤器中显示我的最后一项,我已经添加了显示所有我最新投资组合项目的代码,我只需要按照我的投资组合类别中的类别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 } ?>
感谢您的帮助。
答案 0 :(得分:0)
用户类似
$args = array(
'post_type' => 'portfolio',
'cat' => 'category_id',
'posts_per_page' => 20,
'order' => 'DESC'
);
或尝试
$args = array(
'post_type' => 'portfolio',
'category_name' => 'slug_category',
'posts_per_page' => 20,
'order' => 'DESC'
);
订单键,确定显示帖子的顺序。你可以找到极端引用here