Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barrykooij/984dd29b3992f38ae79223466085e7bf to your computer and use it in GitHub Desktop.
Save barrykooij/984dd29b3992f38ae79223466085e7bf to your computer and use it in GitHub Desktop.
function rp4wp_disable_rposts_on_certain_categories( $display ) {
global $post;
// ID's of categories you wish to exclude of displaying posts
$excluded_categories = array( 96, 100 );
$terms = wp_get_object_terms( $post->ID, 'category' );
if ( ! empty( $terms ) ) {
foreach ( $terms as $term ) {
if ( in_array( $term->term_id, $excluded_categories ) ) {
$display = false;
break;
}
}
}
return $display;
}
add_filter( 'rp4wp_append_content', 'rp4wp_disable_rposts_on_certain_categories');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment