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

on my homepage, I'm using several loops to display posts from different categories in various sections of the page.

The code I'm adding before the loop is :

<?php query_posts('category_name=featured&showposts=5'); ?>

The loop comes just afterwards


        if ( have_posts() ) : 
        /* Start the Loop */
            while ( have_posts() ) : the_post();
            get_template_part( $layout, 'blog-'.get_post_format() );
        else :

        <article id="post-0" class="post no-results not-found clearfix">
            <header class="entry-header">
                <h1 class="entry-title"><?php _e( 'Nothing Found', 'swift' ); ?></h1>
            </header><!-- .entry-header -->

            <div class="entry-content">
                <p><?php _e( 'Apologies, but there are no posts in the current context. Perhaps searching will help find a related 

post.', 'swift' ); ?></p>
                <?php get_search_form(); ?>
            </div><!-- .entry-content -->
        </article><!-- #post-0 -->
        <div class="clear"></div>
    <?php endif; ?>

And I copy paste this with the desired categories. Problem is eventhough I mention shoposts=5, 10 posts show up, whatever number I indicate.

Do you guys have any clues please ?


share|improve this question
do you have sticky posts? are the 5 extra posts always the same? for multiple loops, also read wordpress.stackexchange.com/questions/50761/… – Michael Aug 15 '12 at 21:55

I believe the right parameter would be numberposts

<?php query_posts('category_name=featured&numberposts=5'); ?>
share|improve this answer
Thanks Jonathan. Actually I tried that too, but that didn't work. But I tried with that code : `<?php $custom_query = new WP_Query('posts_per_page=5&cat=137');. As explained on this page digwp.com/2011/05/loops – Garry Aug 15 '12 at 20:29

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.