wes*_*bos 1 php arrays wordpress
我正在尝试根据数组中包含的许多ID来查询帖子.
我的数组(称为$ my_array)如下所示:
Array
(
[0] => 108
[1] => 129
[2] => 145
)
Run Code Online (Sandbox Code Playgroud)
我的查询看起来像这样:
<?php query_posts(array('post__in' => $my_array)); ?>
Run Code Online (Sandbox Code Playgroud)
然而,这只返回一个帖子,帖子具有数组中第一个项目的ID(108).
我的语法错了吗?
$args = array(
'post_type' => 'page',//or whatever type
'post__in' => array(108,129,145)
);
query_posts($args);
Run Code Online (Sandbox Code Playgroud)
要么
$arr=array(108,129,145);
$args = array(
'post_type' => 'page',
'post__in' => $arr
);
query_posts($args);
Run Code Online (Sandbox Code Playgroud)