Stop duplicate posts
-
Hi there,
I love this theme and just have one issue.
On the front page I get duplicate posts if I set a post as Featured or Latest and also include it in another category that is shown on the front page.
I have seen this online but am unable to code it.
1. Defined a empty array in functions.php 2. Fetched that array in widget function of widget with global $arrayname 3. Now in WP_Query, checked if the post being displayed is alreay in array so that we can skip that specific post 4. If not skipped, add id of that post to array 5. Repeat Step 3 and 4 in other widgets Since the array was declared in functions.php, it was available to any function using global keyword. functions.php $donot_include = array(); widgets.php global $donot_include; if(in_array($post->ID , $donot_include)) continue; $donot_include[] = $post->ID; For every widgets.php, I repeated the above code and stopped duplicate posts from re-appearing.
Any help is appreciated.
- The topic ‘Stop duplicate posts’ is closed to new replies.