Discuss your project
Wordpress Front

WordPress: Hide the default category on the front

To be placed in the functions.php file: add_filter( 'list_terms_exclusions', 'global_cat_exclude' ); function global_cat_exclude( $terms ) { if( !is_admin() ) $terms = "AND t.term_id != " . get_option( 'default_category' ) . " "; return $terms; } Repr...

WordPress: Hide the default category on the front


To be placed in the functions.php file:

add_filter( 'list_terms_exclusions', 'global_cat_exclude' );
function global_cat_exclude( $terms ) {
if( !is_admin() )
$terms =  "AND t.term_id != " . get_option( 'default_category' ) . " ";
return $terms;
}

Reproduce this customization today

The principle of the hook remains useful, but the administration screens and WordPress APIs have evolved since the publication. Test the code in a staging environment with the exact version of the site's core, theme, and plugins.

  • Save the files and the database before making any changes.
  • Control user capabilities, nonces, input validation, and output escaping.
  • Place customizations in a dedicated plugin or a child theme to preserve updates.

Reference: official WordPress plugin development manual.

Share this article