Forums

2 While Loops are combining my post count (3 posts)

  1. wilsonf1
    Member
    Posted 9 months ago #

    Hi. I have changed loop.php to now have 2 While Loops that brings back 2 columns of my posts.

    One loop returns posts for 1 of my categories, the other loop brings back all posts other than the previous category.

    My post count is set to 10 in the settings and ideally I want 10 posts per column. But it seems WordPress has put 7 down one side, 3 on the other - despite there being at least 10 of each category. When I click Previous Posts I get a similar problem on the next page.

    Is there a way round it?

  2. alchymyth
    The Sweeper
    Posted 9 months ago #

    have you tried to use the 'posts_per_page' parameter in the query?

    http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

  3. wilsonf1
    Member
    Posted 9 months ago #

    Sorry to be a bit of a tool but can you show me an example of the context you use:

    $query = new WP_Query( 'posts_per_page=-1' );

    As right now this is one of my loop examples:

    <!-- RIGHT COLUMN: Featured Posts -->
    <div style="float:right; width:355px">

    <?php $i=0; ?>
    <?php while ( have_posts() ) : the_post(); ?>

    <?php if (in_category('My Category Title')) { ?>

Reply

You must log in to post.

About this Topic