Created
March 29, 2017 19:25
-
-
Save sblomberg/e68295b4822db373040acc22ef6ce685 to your computer and use it in GitHub Desktop.
Toplytics filter suggestion
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 | |
// Add filter to determine if certain posts should excluded | |
add_filter( 'toplytics_exclude_post', 'check_if_topolytics_should_exclude', 10, 2 ); | |
function check_if_topolytics_should_exclude( $should_exclude, $post_id ) { | |
$excluded_posts = get_peta_excluded_posts(); | |
if ( in_array( $post_id, $excluded_posts ) ) { | |
$should_exclude = true; | |
} | |
return $should_exclude; | |
} | |
function display_my_post() { | |
// filter checks if post should be excluded | |
$exclude_post = apply_filters( 'toplytics_exclude_post', false, $post_id ); | |
if ( true === $exclude_post ) { | |
// Post should be excluded - do not process this post | |
return; | |
} | |
// Continue displaying post if it's not excluded | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment