我正在使用WP 3.0.3,我想从我的查询中排除粘性帖子:
这似乎不起作用:
<?php query_posts( \'posts_per_page=9&cat=-1,-2&ignore_sticky_posts=1\' );?>
为了获得粘性贴子,我使用以下方法:
$sticky = get_option(\'sticky_posts\');
$args = array(
\'posts_per_page\' => 1,
\'post__in\' => $sticky
);
query_posts($args);
最合适的回答,由SO网友:Jan Fabry 整理而成
ignore_sticky_posts
在WordPress 3.1中引入。在此版本之前,您可以使用caller_get_posts
, 这将产生相同的效果(当您通过get_posts()
, 使用相同的WP_Query
类,但应忽略粘性帖子)。这个名字有点混乱,因此changed in 3.1.