Make WordPress sticky posts behave as normal using caller_get_posts=1 isn't working
I'm making a specific single.php template. It's using a jQuery slider to slide from one post to the next. In order to show the right post first, I have to use 2 loops - one to call the first single post, and then another loop to call all the other posts in the category.
This I do like this (might be a bit mucky, I'm no PHP guru)
<ul id="tour-items">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</li>
<?php endwhile; endif; ?>
<?php $briefingsposts = new WP_Query(array(
'caller_get_posts' => 1,
'category_name' => Briefings,
'offset' => 1
)); ?>
<?php while ($briefingsposts->have_posts()) : $briefingsposts->the_post(); ?>
<li>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</li>
<?php endwhile; ?>
However, if the first post is a sticky post, it's repeating in the category loop despite the 'offset' => 1 which I assume is bec开发者_JAVA技巧ause it's doing it's sticky behaviour and sticking itself to the top.
I've tried using 'caller_get_posts' => 1 in the array but it doesn't seem to make any difference at all. I dont want to exclude sticky posts, just make them behave as normal. Is there a way that might work within my queries?
Thanks,
Laura
This:
$briefingsposts = new WP_Query(array(
'caller_get_posts' => 1,
'category_name' => Briefings,
'offset' => 1,
'post__not_in'=>get_option('sticky_posts')
));
Should do the trick.
精彩评论