在下面的脚本中,post\\u not\\u In参数似乎不起作用,除非我在数组()中硬编码post id。有什么突出的吗?
如果一个项目在类别中,但也在post\\u not\\u in中,那么get的先例是什么?
get\\u选项(\'sticky\\u posts\')是一个具有var\\u dump=array(1){[0]=>int(6)}
$myposts = get_posts(
array(\'cat\' => "$cat,-$catHidden",
\'post__not_in\' => array($post->ID, get_option(\'sticky_posts\')),
\'numberposts\' => 10;
)
);
foreach($myposts as $idx=>$post){//do something}
最合适的回答,由SO网友:Bainternet 整理而成
尝试:
$not_in = get_option(\'sticky_posts\');
$not_in[] = $post->ID;
$myposts = get_posts(
array(\'cat\' => "$cat,-$catHidden",
\'post__not_in\' => $not_in,
\'numberposts\' => 10;
)
);
foreach($myposts as $idx=>$post){//do something}
希望这有帮助