• I am trying to set up a 2 column system. I can get the two column just fine but the problem is they repeat the same posts. Is there a way I can have one column pull the first 6 and the second to pull the next 6? I am using this as my code:

    <?php
    $my_query = new WP_Query(‘category_name= ‘. $category .’&showposts=6’);
    while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID;
    ?>

    I am using this code in 2 separate divs to create the two columns.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Assuming that the bit of code that you posted works for the 6 posts, a quick fix would be something like this…

    <?php $my_query = new WP_Query('category_name= '. $category .'&showposts=12'); $postNumber = 0;
    
    while ($my_query->have_posts() && $postNumber < 6) : $my_query->the_post();$do_not_duplicate = $post->ID; ?>
    <!-- Sidebar 1 Code Here -->
    <?php $postNumber++; endwhile; ?>
    
    while ($my_query->have_posts() && $postNumber < 12) : $my_query->the_post();$do_not_duplicate = $post->ID; ?>
    <!-- Sidebar 2 Code Here -->
    <?php $postNumber++; endwhile; ?>
    Thread Starter uspinnak

    (@uspinnak)

    Thanks for that help I didn’t even think of that. I modified it a little bit to try and get the call to pull one category per category page instead of information from all the most recent posts. I changed the code to this assuming that it would just pull directly from category information.

    if (have_posts()) : query_posts('posts_per_page=12');
    while (have_posts() && $postNumber < 6) : the_post();$do_not_duplicate = $post->ID; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PhP Call Help’ is closed to new replies.