10-23-2019, 07:43 AM
(This post was last modified: 10-24-2019, 08:19 PM by Kingsolomon.)
Hello guy Today am going to be teaching you how to hide a specific category from showing up in post section.
Many having been asking
I have a category about the catalog, news1 Which I use to get a post on the main page. The problem is that I don't want the news1 category name to appear in these posts, but I want other categories to be displayed.
How can I do this?
Login to your wordpress site
Click on Appearance
Editor
Function.php
Past the below code in your function.php
add_filter( 'get_the_categories', function ( $categories, $id ) {
foreach ( $categories as $i => $term ) {
if ( 253 == $term->term_id ) {
unset( $categories[$i] );
}
}
return $categories;
}, 10, 2 );

Change the { if ( 253 (253) to your category id you wish to hide
How to find category id in wordpress
Click On Posts > Categories >
Find the one you want to hide, and click on the category on the url box scroll to the id and copy the id
Or
Press and hold the text you will see the category id
