Posts Tagged ‘the loop’

How To: Avoid Duplicate Posts

28
responses

A reader writes in: I’m developing a new theme and I’m having trouble getting duplicate posts from showing when running two loops (one standard loop and one from a specific category). Even when I copied the specific code from directly from the codex, it was not working. The Codex article the reader mentioned was regarding the Loop. Although the example shows how to avoid a single duplicate post, it doesn’t show how to avoid duplicating multiple posts. Here’s how to show two individual loops without duplicating posts in either loop. Step 1: Add a ‘posts_where’ Function A WordPress filter is needed to accomplish this, and we’re going to be tapping into the ‘posts_where‘ filter. The reason being is we need to modify the query used for the loop and exclude some posts. Here’s the function we’ll be using called post_strip: function post_strip($where) { global $myPosts, $wpdb; $where .= " AND […]

[Continue Reading...]



Obviously Powered by WordPress. © 2003-2013

css.php