[英]How to write WP_query for the post ids in WordPress
我是 WordPress 的新手,我正在尝试编写一个循环查询来使用 post_ids 获取帖子。
请找到我尝试过的以下代码。
$current_query = new WP_Query(
[
//'post_type' => 'snippet',
'post__in' => $postids,
]
);
当我尝试打印查询和它作为帖子的帖子类别时,但我想要一些特定的类别,当我在数组 args 中添加相同的类别时,它给了我其他查询,它给出了 null。 有人可以帮助我吗?
$args = array(
'post_type' => 'snippet',
'post__in' => array(123, 345, 678)
);
$postsbyid = get_posts($args);
foreach ($postsbyid as $postbyid) :
//Do something
endforeach;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.