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

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'             => ''
share|improve this question
can you paste the arguments that you are passing to get_posts()? – Will the Web Mechanic Jun 19 '14 at 22:39
@Will the Web Mechanic arguments included. – audaz802 Jun 19 '14 at 22:54

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.

share|improve this answer
It should but it doesn't – audaz802 Jun 19 '14 at 23:28
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 the Web Mechanic Jun 20 '14 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. – audaz802 Jun 20 '14 at 3:53

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.