Exclude posts already displayed

If you’re using the Display Posts Shortcode multiple times in one page, you can use this to exclude already displayed posts from new shortcode queries. This will prevent duplicate posts.

If you have other, non-Display Posts queries running on the page and would like to exclude them as well, you’ll need to modify those queries to add the post ID to the global $dps_exclude variable.

This code snippet goes in a core functionality plugin or Code Snippets.

Filters used:

Published by Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributor to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.