Display of categories by url
-
Hi Everyone,
I don’t want to disable the display of the categorys with url like :
https://www.kevinlegall.fr/category/graphisme/add_action('template_redirect', 'meks_remove_wp_archives'); function meks_remove_wp_archives(){ //If we are on category or tag or date or author archive if( is_category() || is_tag() || is_date() || is_author() ) { global $wp_query; $wp_query->set_404(); //set to 404 not found page } }
It works pretty well but now someone told me that it wasn’t a good solution and I tried to write it differently :
function custom_disable_frontend_categories( $args, $taxonomy, $object_type) { if ( $taxonomy == 'category' ) { $args['publicly_queryable'] = false; $args['rewrite']['with_front'] = false; } return $args; } add_filter('register_taxonomy_args', 'custom_disable_frontend_categories', 10, 3);
That solution makes an error, and I don’t know how to do.
PS I work with wordpress 5.4.1–fr_FR and php 7
Thank you everyone,
KevinThe page I need help with: [log in to see the link]
- The topic ‘Display of categories by url’ is closed to new replies.