Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created October 26, 2017 19:28
Show Gist options
  • Save billerickson/67972e07774176d3b30d2ef3eeaa63e0 to your computer and use it in GitHub Desktop.
Save billerickson/67972e07774176d3b30d2ef3eeaa63e0 to your computer and use it in GitHub Desktop.
<?php
add_action( 'genesis_after_entry', 'genesis_add_id_to_global_exclude', 9 );
/**
* Modify the global $_genesis_displayed_ids each time a loop iterates.
*
* Keep track of what posts have been shown on any given page by adding each ID to a global array, which can be used any
* time by other loops to prevent posts from being displayed twice on a page.
*
* @since 2.0.0
*
* @global array $_genesis_displayed_ids Array of displayed post IDs.
*/
function genesis_add_id_to_global_exclude() {
global $_genesis_displayed_ids;
$_genesis_displayed_ids[] = get_the_ID();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment