Multiple Loops with recent activity category issues
-
Hello,
I am in the process of building a site for a client. I am running across issues for the front-page template I have created.
I have 5 loops on the front-page.
(recent activity, campaigns, news, etc..)For the first loop I used:
[please use the code button to mark your code]
<!– the loop for recent activity –>
<?php query_posts(‘posts_per_page=3’); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
$do_not_duplicate[] = $post->ID;?>Then for each subsequent loop I use
<?php query_posts(‘category_name=giveo-campaigns&posts_per_page=1’); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
if (in_array($post->ID, $do_not_duplicate)) continue; ?>It seems to work for the most part. However, some of the loops do not display posts at all. If I set the first query to:
“array(‘posts_per_page’=> ‘3’, ‘orderby’ => ‘rand’)”
Then refresh the page, it will sometimes display all of the posts correctly so there must be an issue with reseting $do_not_duplicate?
I have tried unset($do_not_duplicate) to no avail.It may just be that it is 4 a.m. but I cannot seem to find the issue. Any help would be appreciated. The site is at https://pathfindersolutions.org/wordpress
Thanks,
Mike
- The topic ‘Multiple Loops with recent activity category issues’ is closed to new replies.