如何在WP_Query()中添加多个标记。所以,我有三个标签:
姓氏(标签ID =" 30")
$args = array(
'post_type' => 'post',
'paged'=>$paged,
'posts_per_page' => 15,
'orderby' => 'date',
**'tag_id' => array(10,20,30),**
'order' => 'DESC'
);
当然上面不起作用。
如何显示多个标签的帖子?
谢谢!
答案 0 :(得分:2)
有一个tag__in
参数专门用于此:
$args = array(
'post_type' => 'post',
'paged'=> $paged,
'posts_per_page' => 15,
'orderby' => 'date',
'tag__in' => array(10,20,30),
);
答案 1 :(得分:2)
如果你正在使用WP_Query,那么你可以这样做。
asadmin redeploy --keepstate=true --name=taskee-1.0-SNAPSHOT target/taskee-1.0-SNAPSHOT.war
OR
//Display posts that are tagged with both tag id 37 and tag id 47:
$query = new WP_Query( array( 'tag__and' => array( 37, 47 ) ) );
有关详情,请访问官方链接https://codex.wordpress.org/Class_Reference/WP_Query