Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mhmoudsami/a54647556be818f5e21046d4bda271c6 to your computer and use it in GitHub Desktop.

Select an option

Save mhmoudsami/a54647556be818f5e21046d4bda271c6 to your computer and use it in GitHub Desktop.
hide div in single post if post belongs to category ID
add_filter('body_class', 'hide_div_if_post_belongs_to_category');
function hide_div_if_post_belongs_to_category($classes) {
if ( is_singular('post') )
{
if (in_category($category_id , get_the_ID()))
{
$classes[] = 'hide-this-div';
}
}
return $classes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment