0

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

<?php 

        if ( have_posts() ) : 
        /* Start the Loop */
            while ( have_posts() ) : the_post();
            get_template_part( $layout, 'blog-'.get_post_format() );
            endwhile;
        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 ?

Thanks

1

1 Answer 1

0

I believe the right parameter would be numberposts

<?php query_posts('category_name=featured&numberposts=5'); ?>
1
  • 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, 2012 at 20:29

Your Answer

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

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