Skip to content

Instantly share code, notes, and snippets.

@bekarice
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save bekarice/fed3051d33e87fd50d53 to your computer and use it in GitHub Desktop.

Select an option

Save bekarice/fed3051d33e87fd50d53 to your computer and use it in GitHub Desktop.
Exclude categories from Related Posts for WordPress
/**
* Removes RP4WP display when a post is in a certain category
**/
function br_disable_rp4wp_category( $content ) {
if ( in_category( 'excluded-category-slug' ) ) {
add_filter( 'rp4wp_append_content', '__return_false');
}
return $content;
}
add_filter( 'the_content', 'br_disable_rp4wp_category' );
// Here's how to use multiple categories instead
// Replace line 6 with this & add as many categories as needed:
if ( in_category( array( 'category-1-slug', 'category-2-slug', 'category-3-slug' ) ) ) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment