Skip to content

Instantly share code, notes, and snippets.

@cparkinson
Created October 7, 2020 22:00
Show Gist options
  • Save cparkinson/ff8ae85d4756279cf66df41f99f5d25d to your computer and use it in GitHub Desktop.
Save cparkinson/ff8ae85d4756279cf66df41f99f5d25d to your computer and use it in GitHub Desktop.
wp exclude category from postmeta
/**
* hide 'for parents' and 'featured' categories in list of cats in post's postmeta
*/
function ca_response_exclude_category_from_postmeta( $categories ) {
$exclude = array( 'featured','for-parents' );
foreach ( $categories as $index => $category ){
if ( in_array( $category->slug, $exclude ) ){
unset( $categories[ $index ] );
}
}
$categories = array_values( $categories );
return $categories;
}
add_filter( 'get_the_categories', 'ca_response_exclude_category_from_postmeta' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment