WordPress如何查询指定的多个ID的POST文章

追格官方小助手/ 2022年03月21日/ WordPress/ 浏览 1508

WordPress一些特别的页面需要列出指定列表文件,我们可以使用WP_Query实现查询指定的多个ID的POST文章。


示例代码如下:


$myarray = array(144, 246);

$args = array(
   'post_type' => 'ai1ec_event',
   'post__in'      => $myarray
);
// The Query
$the_query = new WP_Query( $args );


参考资料:How do I use WP_query with multiple post IDs?

发表评论

暂无评论,抢个沙发...

客服 工单