WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The code below writes out a list of the most recent posts. However, it does not appear to be skipping over sticky posts although I'm using 'post_not_in' => get_option('sticky_posts'). What am I missing?

$myquery = new WP_Query();
    'cat' => "-$cat,-$catHidden",
    'post_not_in' => get_option('sticky_posts')
$myrecentpostscount = $myquery->found_posts;

if ($myrecentpostscount > 0) 
{ ?>
<div><h4>Recent Posts</h4>
global $post;
$current_page_recent = get_post( $current_page );
$myrecentposts = get_posts(array('post_not_in' => get_option('sticky_posts'), 'cat' => "-$cat,-$catHidden",'numberposts' => $cb2_recent_count));
foreach($myrecentposts as  $idxrecent=>$post) {
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
share|improve this question
up vote 1 down vote accepted

You are lacking a one underscore in parameter, it should be post__not_in.

Also the better way is to use caller_get_posts parameter (it will be deprecated and replaced with more aptly named ignore_sticky_posts in 3.1 that will do same thing) that will keep sticky posts in results if they fit, but will prevent them from jumping to the top.

See Sticky Post Parameters in Codex.

share|improve this answer
Thanks Rarst! I can't believe it was that easy. – Scott B Jan 6 '11 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.