about avoiding Duplicate post using pods template
-
Hi,
(I am sorry if there is a grammar mistake)I am using the following code to avoid Duplicate posts. It works well with my query but not with pods template.
add_filter('post_link', 'track_displayed_posts'); add_action('pre_get_posts', 'remove_already_displayed_posts'); $displayed_posts = []; function track_displayed_posts($url) { global $displayed_posts; $displayed_posts[] = get_the_ID(); return $url; // don't mess with the url } function remove_already_displayed_posts($query) { global $displayed_posts; $query->set('post__not_in', $displayed_posts); }
I tried to write in ‘where’ filed ‘t.ID NOT IN $displayed_posts’ but it did work. I think I could make an if statement inside of the template but I guess I will lose some post count. Is there away to avoiding Duplicate posts?
Best regards,
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘about avoiding Duplicate post using pods template’ is closed to new replies.