我一直在读这个@nacin 通过我以前使用的query\\u帖子了解wp\\u query。
我想要的是:
将其放入模板文件
我现在应该说works. 然而,这是一个流量非常高的网站,我想确保这是最好的方式,我不确定我是否正确使用wp\\u query来实现这一点,因为原始查询基本上是相同的,只是有和没有粘性帖子。
global $wp_query;
$wp_query = new WP_Query(array(
\'post_type\' => \'post\',
\'posts_per_page\' => 1,
\'category__in\' => 3,
\'post__in\' => get_option( \'sticky_posts\' )
));
while ($wp_query->have_posts()) : $wp_query->the_post();
$exclude_featured = $post->ID;
echo the_title();
echo \'<br />\';
endwhile;
echo \'<br />\';
echo \'<br />\';
global $wp_query;
$args = array_merge(
$wp_query->query_vars,
array(
\'post__in\' => null,
\'posts_per_page\' => 999,
\'ignore_sticky_posts\' => 1,
\'post__not_in\' => array($exclude_featured)
)
);
query_posts( $args );
while ($wp_query->have_posts()) : $wp_query->the_post();
if ( $exclude_featured == get_the_ID() )
continue;
echo the_title();
echo \'<br />\';
endwhile;
谢谢大家的帮助。