• When using WP_Query to setup multiple loops, if you attempt to pass showposts to limit the number of posts to display, the query to the database does not work properly. Examples:

    Category Queries
    new WP_Query(‘category_name=mycat’); //works
    new WP_Query(‘category_name=mlb&showposts=5’); //showposts does nothing

    Author Queries
    new WP_Query(‘author_name=myauth’); //works
    new WP_Query(‘author_name=myauth&showposts=1’); //showposts does nothing

    In all these blocks of code I’m using a standard while loop, and I need to limit the data returned in the db query.

Viewing 1 replies (of 1 total)
  • I got it to work with a slightly different loop.

    <?php
        $recentPosts = new WP_Query();
        $recentPosts->query('meta_key=Quote&showposts=1&orderby=rand');
    ?>
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>

    Hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘‘showposts’ breaks WP_Query’ is closed to new replies.