Skip Navigation

[Resolved] Hide Uncategorized term in View of taxonomy terms

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 6 years ago.

Author
Posts
#1150145

Is there a way to hide the uncategorised item in all these views?

#1150146

You can remove the uncategorized term from all posts, specify a different default term for Posts in wp-admin > Settings > Writing, and delete the term from the site completely. Or, you can use custom code to suppress this term in Views of this taxonomy. I have a code snippet that will help. Add this to your child theme's functions.php file, or to a new snippet in Toolset > Settings > Custom Code:

add_filter( 'wpv_filter_taxonomy_query', 'prefix_modify_tax_query', 10, 3 );
function prefix_modify_tax_query( $tax_query_settings, $view_settings, $view_id ) {
  $views = array( 222, 333, 444 );
  if( in_array($view_id, $views) ) {
    $tax_query_settings['exclude'] = 1;
  }
  return $tax_query_settings;
}

Change 222, 333, 444 to be a comma-separated list of the numeric IDs of all the Views where you want to hide the Uncategorised item. If the Uncategorized term ID isn't 1, you must also change 1 to match the correct term ID. Usually it's 1 unless you change it. You can find a term ID by hovering over the term name in the wp-admin list of terms for this taxonomy.