$do_not_duplicate and functions.php
-
I’ve got some additional front-page loops being called from my functions.php file via my theme, and they’re working great. Only trouble is I don’t seem to be able to get my actual main loop template to respect the do_not_duplicate array. This is the code I’ve got now, which is very wrong somehow:
In functions.php:
global $do_not_duplicate; $do_not_duplicate = array(); function latest_template($category){ if (is_front_page() && !is_paged()){ $temp_query = $wp_query; $my_query = new WP_Query('category_name='.$category.'&posts_per_page=4'); // Start of 'The Loop' if(have_posts()){ while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID;
[etc., to the end of the latest_template function]
In the post loop template:
global $do_not_duplicate; // Start of 'The Loop' if (is_front_page()){ query_posts(array('post__not_in'=>$do_not_duplicate)); } if(have_posts()){ while (have_posts()) : the_post();
All the posts that are getting pulled in by the function in functions.php are also appearing in the loop, even though I have attempted to create a separate query for the front page that will exclude them.
I’m sure the problem is very elementary, but I’m not very strong in PHP and globals are a little over my head (apparently), so I haven’t been able to spot the problem. Can anyone point me in the right direction?
Thank you!
- The topic ‘$do_not_duplicate and functions.php’ is closed to new replies.