X

Hide Posts in the “uncategorized” Category

Snippets by IsItWP

By default, WordPress has an “uncategorized” category with a sample post. You may want to hide posts in the “uncategorized” category or default category if you’ve renamed it.

Instructions: Add the following code to the functions.php file of your WordPress theme to hide posts in the “uncategorized” category or the default WordPress category with any name.


<?php
	// Hide the display of something if it has the category named "Uncategorized"
	if( !in_category( 'Uncategorized' ) ) {
        	// do something like:
        	the_category( ', ' );
        }

	// Hide the display of something if it uses the default category, initially named "Uncategorized"
	if( !in_category( 1 ) ) {
        	// do something like:
        	the_category( ', ' );
        }

?>

You may also enjoy listing some posts for each category.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[60% OFF Today!]
[60% OFF Today!]
[10% OFF Today!]
[10% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]