Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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… – Michael Aug 15 '12 at 21:55

1 Answer 1

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 – 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.