Wordpress post循环中的多个标记id
如何在WP_Query()中添加多个标记。因此,我有三个标签:Wordpress post循环中的多个标记id,wordpress,tags,Wordpress,Tags,如何在WP_Query()中添加多个标记。因此,我有三个标签: 名字(标签id=“10”) 中间名(标记id=“20”) 姓氏(标签id=“30”) 当然,上述方法不起作用 如何显示来自多个标记的帖子 谢谢 有一个参数专门用于此: $args = array( 'post_type' => 'post', 'paged'=> $paged, 'posts_per_page' => 15, 'orderby' =>
$args = array(
'post_type' => 'post',
'paged'=> $paged,
'posts_per_page' => 15,
'orderby' => 'date',
'tag__in' => array(10,20,30),
);
有一个参数专门用于此:
$args = array(
'post_type' => 'post',
'paged'=> $paged,
'posts_per_page' => 15,
'orderby' => 'date',
'tag__in' => array(10,20,30),
);
如果您使用的是WP_查询,那么您可以执行以下操作
//Display posts that are tagged with both tag id 37 and tag id 47:
$query = new WP_Query( array( 'tag__and' => array( 37, 47 ) ) );
或
欲了解更多信息,请访问官方链接,如果您使用的是WP\u查询,则可以执行以下操作
//Display posts that are tagged with both tag id 37 and tag id 47:
$query = new WP_Query( array( 'tag__and' => array( 37, 47 ) ) );
或
更多信息,请访问官方链接