metinsaylan // rogue developer

Remove unwanted “Uncategorized” links from your posts

Categories are a great way to organize your posts. If you don’t want to categorize a post and leave category field blank, WordPress uses default category for the post. Here, we will show you a simple trick to remove “Uncategorized” links from your posts. ***

Open your functions.php file and add the following code:

function remove_uncategorized_links( $categories ){

	foreach ( $categories as $cat_key => $category ){
		if( 1 == $category->term_id ){
			unset( $categories[ $cat_key ] );
		}
	}

	return $categories;
	
} add_filter('get_the_categories', 'remove_uncategorized_links', 1);

This snippet will remove Uncategorized item from the category list, so it won’t be displayed on your site.

I hope you found this trick useful. Cheers.

Search Remove unwanted “Uncategorized” links from your posts on Google