[Resolved] “Sticky” Qualifier for query_posts
I think this should do it:
does get_option(‘sticky_posts’) return a comma separated list of all posts that have the sticky option selected?
Nevermind … it seems like it returns an array of Post IDs for posts that have been marked sticky.
This new feature needs some serious documentation. The possibilities of the sticky options are much greater than just “sticking a post to the homepage”.
Thank you Otto42, I’ve got that example working to fetch only sticky post.
Now, on the same page (in a different loop), I’d like to fetch posts that are NOT sticky. So, I’d like to exclude those marked as sticky.
My front page has a feature box at the very top that I’d like to designate as the sticky spot, and then, I have separate blocks for the posts within each category. Right now, the sticky-spot is working great, thanks to your suggestion, but I can’t figure out a way to exclude sticky posts from the others.
Specifically, I have code that looks somewhat like this:
<?php query_posts('showposts=3&cat=6'); ?> <?php while (have_posts()) : the_post(); ?> ... stuff ... <?php endwhile; ?>
I’m wondering how I can modify my query_posts so that I can exclude those marked as sticky
My understanding of “caller_get_posts=1” means that it still fetches ALL posts with the category, it just doesn’t bring the sticky to the top.
So, if I have …
<?php query_posts('caller_get_posts=1&showposts=3&cat=6'); ?>
… it will still bring back the sticky posts.
So, it sounds like that’s the fix for me, but it’s really not.
lairdf, did you figure it out? I’m trying to do the exact same thing. can’t get a query returned that excludes the sticky posts.
I am working on a new site and wanted to use the new sticky function to create a highlight area (“Items to watch”). Otto’s solution works great to pull the sticky posts out, but if there are no sticky posts, it is returning the regular stream of posts and spits out the number of them defined in the settings panel.
anyone have a way to degrade something like this in case there are no posts specified as sticky?
query_posts(array( "post__not_in" => get_option("sticky_posts") ));
to get rid of all the sticky posts in the loop. Strange that it’s not in the documentation. Worked for me, hope it works for you too 🙂
Incorporated some of the ideas from this thread into:
- The topic ‘[Resolved] “Sticky” Qualifier for query_posts’ is closed to new replies.