Created
November 16, 2015 04:07
-
-
Save reasonstousegenesis/cfdec91f99f06516b6e5 to your computer and use it in GitHub Desktop.
Prevent posts appearing more than once across all loops on your site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste the code BELOW this line into your child theme functions. | |
/** | |
* Prevent posts appearing more than once across all loops on your site | |
* | |
* @author Reasons to Use Genesis | |
* @link http://reasonstousegenesis.com/genesis-global-exclude/ | |
*/ | |
remove_action( 'genesis_after_entry', 'genesis_add_id_to_global_exclude' ); | |
add_action( 'genesis_after_entry', 'rtug_add_id_to_global_exclude' ); | |
function rtug_add_id_to_global_exclude() { | |
global $wp_query, $_genesis_displayed_ids; | |
$_genesis_displayed_ids[] = get_the_ID(); | |
$wp_query->set( 'post__not_in', (array) $_genesis_displayed_ids ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Paste the code BELOW this line into your child theme functions. | |
/** | |
* Prevent posts appearing more than once across all loops on your site (XHTML) | |
* | |
* @author Reasons to Use Genesis | |
* @link http://reasonstousegenesis.com/genesis-global-exclude/ | |
*/ | |
remove_action( 'genesis_after_post', 'genesis_add_id_to_global_exclude' ); | |
add_action( 'genesis_after_post', 'rtug_add_id_to_global_exclude' ); | |
function rtug_add_id_to_global_exclude() { | |
global $wp_query, $_genesis_displayed_ids; | |
$_genesis_displayed_ids[] = get_the_ID(); | |
$wp_query->set( 'post__not_in', (array) $_genesis_displayed_ids ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment