Archived topic
Hide link to category on category archives
3 replies · Started by mkjj on April 17, 2021
I would like to remove the category link on category archive pages. I can't use the customizer for that. It would remove all links, but I want them to appear on the blog page. It simply doesn't make sense in our case, since we only use one category per post. So, no need to include a link that refers to the page itself.
I guess, I'll have to use CSS to remove the link. Or can you recommend a cleaner solution?
Thank you!
Hi there,
you can use the option_generate_blog_settings filter:
https://docs.generatepress.com/article/option_generate_blog_settings/
So this PHP Snippet should do what you need:
add_filter( 'option_generate_blog_settings', 'db_remove_category_archive_terms' );
function db_remove_category_archive_terms( $options ) {
if ( is_category() ) {
$options['categories'] = false;
}
return $options;
}
Adding PHP: https://docs.generatepress.com/article/adding-php/
Wow, thank you very much. This is an awesome feature. I'm even more impressed.
Glad to be of help :)