I have a custom query using get_posts() that besides ignoring sticky on its main query, ignores sticky posts on main loop. Reading around I've found that get_posts() have some trouble with sticky but couldn't found a solution to my needs.

The sticky post is shown normally but not at the top, which is unexpected.

How can I get it working properly?

args I'm using:

'numberposts'       => 5, 
'category_name'     => '',
'post_status'       => 'publish', 
'post_type'         => 'post',
'meta_key'          => '',
'orderby'           => '',
'order'             => ''
  • can you paste the arguments that you are passing to get_posts()?
    – Will
    Commented Jun 19, 2014 at 22:39
  • @Will the Web Mechanic arguments included. Commented Jun 19, 2014 at 22:54

1 Answer 1


From the function reference for get_posts():

For full parameters list see WP_Query.

From the WP_Query reference:

ignore_sticky_posts (boolean) - ignore sticky posts or not (available with Version 3.1, replaced caller_get_posts parameter). Default value is 0 - don't ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned.

So, with that, if you add ignore_sticky_posts => 0 to your array of arguments being passed to get_posts() your sticky posts should be output at the top as expected.

  • It should but it doesn't Commented Jun 19, 2014 at 23:28
  • 1
    so, yeah, I dug into the get_posts() function - it sets ignore_sticky_posts to true because if it's not then it causes a runaway loop and will shut down everything. Sorry, you're going to have to either adapt one of the solutions you've read about to work for you or come up with one on your own. Why not use WP_Query?
    – Will
    Commented Jun 20, 2014 at 0:37
  • using WP_Query will cost me a time that I don't have restructuring all the code. Anyway thank you for your response. Commented Jun 20, 2014 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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