Created
August 14, 2019 13:56
-
-
Save Swapnildhanrale/9597da281cc25ab1032ab96a34de8c7c to your computer and use it in GitHub Desktop.
Show only one category from the the_category_list() function.
This file contains hidden or 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
<?php | |
add_filter( 'the_category_list', function( $categories ) { | |
if( ! empty( $categories ) && is_array($categories) ) { | |
foreach ($categories as $key => $cat) { | |
if( ! $cat->parent ) { | |
$ob[] = $categories[$key]; | |
return $ob; | |
} | |
} | |
} | |
return $categories; | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment