In my site I've does some coding based on the category like in_category('featured')
do something. Now, this is only applicable to posts only. Also the posts which is associated with featured
category is also associated with other category too. As it is only associated with featured
category to show up with special design thats it.
Now I know that this question has been discussed before here many time, but not exactly what I'm looking for. So before downgrading this question, red it properly.
Here in this post is there a quick way to hide category from everywhere? the following function is provided to exclude some categories, but I don't want to exclude it I just want to hide it.
add_action('pre_get_posts', 'wpa_31553' );
function wpa_31553( $wp_query ) {
//$wp_query is passed by reference. we don't need to return anything. whatever changes made inside this function will automatically effect the global variable
$excluded = array(272); //made it an array in case you need to exclude more than one
// only exclude on the front end
if( !is_admin() ) {
$wp_query->set('category__not_in', $excluded);
}
}
As an example let's say a post is associated with featured
category and also associated with Work
category. Now as featured
is alphabetically comes first the breadcrumb (using Yoast SEO Breadcrumb) will show featured
as category name also the post meta (shown below the posts) will show up both category names i.e. featured
and work
.
That is why I want to hide the featured
category completely so that no front end user will ever have idea that featured
category exists. It wont show up in breadcrumb, post meta, post category list, no where. It will remain hidden but in the backend code it will still work when I try to do specific with those posts inside featured
category using in_category('featured')
.
Does anyone know how to obtain this category hiding (not excluding) feature.