Created
October 7, 2020 22:00
-
-
Save cparkinson/ff8ae85d4756279cf66df41f99f5d25d to your computer and use it in GitHub Desktop.
wp exclude category from postmeta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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