Skip to content

Instantly share code, notes, and snippets.

@sblomberg
Created March 29, 2017 19:25
Show Gist options
  • Save sblomberg/e68295b4822db373040acc22ef6ce685 to your computer and use it in GitHub Desktop.
Save sblomberg/e68295b4822db373040acc22ef6ce685 to your computer and use it in GitHub Desktop.
Toplytics filter suggestion
<?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