So, what happens? Nothing? Something?
A couple of debugging things:
1) ignore_sticky_posts is Boolean, so try this instead:
$query->set( 'ignore_sticky_posts', true );
2) Be sure to target only the front end, in the correct context:
All contexts on the front end:
if ( ! is_admin() && $query->is_main_query() ) {
}
Just the blog posts index:
if ( $query->is_home() && $query->is_main_query() ) {
}
3) Make sure you remove all references to query_posts() in the template, and output only the default loop instantiation.
p.s. Mad? Nah. Ain’t nobody got time for that!
Ah, what happened: I put the code you described in the other post in my functions.php and made my Loop ‘normal’, and I saw sticky posts on top of my latest posts.
This is my blog: http://vandenb.com/
And where it says at the bottom ‘de goeie stukjes’, i’m showing my stickies.
I’m using the dangerous code now. But I don’t want to.
The problem I have: I’m just beginning with WordPress, have no php-experience, and a lot of things that should help me on this forum or in the Codex are pretty hard to grasp, because people say: here, use this code. But very often they don’t give any context. So I don’t know where to go with that code.
I think it’s really really great all these people out here are helping us n00bs, but ouch, I feel stupid now, I have to ask:
Where do I use the code examples you are giving me? How should my Loop be? And my functions.php?
I was looking for the same thing as you, Vandenb. In my case, I’m using Sticky Posts only to select which posts are to go in a slider on the front page. But otherwise I do not want them to appear at the top any time I call The Loop. They should be in chronological order with the rest of the posts.
So using Chip’s recommendation, I added this to my theme’s functions.php:
//Makes sure sticky posts don't get placed at the top of The Loop
function nostickies_filter_pre_get_posts( $query ) {
if ( ! is_admin() && $query->is_main_query() ) {
$query->set( 'ignore_sticky_posts', true );
}
}
add_action( 'pre_get_posts', 'nostickies_filter_pre_get_posts' );
That way I don’t have to change anything in The Loop, which looks something like this:
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="post">
<p class="date"><?php the_time('d M Y'); ?></p>
<h2 class="posttitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="postcontent"><?php the_content(); ?></div>
</div>
<?php endwhile; ?>
<?php endif; ?>
And it works!
I don’t have pagination currently but I’ll implement it to make sure nothing’s broken there and let you know the results.
I installed the WP-PageNavi plugin and there’s no issue with its pagination that I can see. Thanks for the help, Chip!