繁体   English   中英

来自特定类别AND标签的wordpress显示帖子

[英]wordpress display posts from particular category AND tag

这一定有可能,但是我还没有找到任何文档。 我正在尝试显示某个类别和标签的帖子。 像这样:

if (in category 'featured' and has tag 'gcse') { output 3 most recent posts }

这是我la脚的尝试,显然不起作用:

<?php
get_the_category()
$args = array('tag_slug_' => array('gcse'),category=featured);
$postslist = get_posts( $args );
foreach ($postslist as $post) :  setup_postdata($post); ?>
<ul>
<li><?php the_title(); ?></li>
</ul>
<?php endforeach; ?>

谢谢

我知道了...

<?php $postsLatest = get_posts('&tag=gcse&category=24&numberposts=3'); foreach($postsLatest as $post) { ?>                  
        <h4><a href="<?php the_permalink() ?>" target="_parent"><?php the_title(); ?></a></h4>      
    <?php } ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM