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'm using this to retrieve posts on my index page:

<?php $posts = get_posts( "category=13&numberposts=2" ); ?> 
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?> 


Is there a way to include sticky posts on loops like that one? Or I'll have to use WP_Query?

share|improve this question
That will include sticky posts, if they are in the category you pick. Are you trying to include sticky posts in addition to the category you choose? – s_ha_dum Apr 10 '13 at 2:01
get_posts() takes the same parameters as WP_Query() codex.wordpress.org/Template_Tags/get_posts#Parameters – Michael Apr 10 '13 at 10:08
I would like to get the sticky posts of each category. – Felipe Dário Apr 11 '13 at 2:16

Your Answer


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

Browse other questions tagged or ask your own question.