Delete Uncategorized from Posts
If you were moving your blogs to WordPress, you may have noticed that all migrated posts are categorized as Uncategorized which will make your readers think your blog is under construction or unprofessional. But how can we delete Uncategorized from posts in WordPress?
In this post, we will discuss several possible ways to delete it, and then see their pros and cons respectively.
- Changing “Default Category”
- Using “Quick Edit” for Every Post
- Renaming Uncategorized
- Deleting Rows From Tables Directly
- Bulk Actions Edit
1. Changing “Default Category”
I know you can change the default category for future posts, but current posts with Uncategorized remain unchanged. Therefore, changing default category is just a preventive action, not a correction. But you have to do it in case your new posts fall into the same trap. So I hope you can take this action before doing any other modifications.
Here are the steps.
- Use your mouse to hover Settings > Writing in /wp-admin.
- Select anyone you like for your default category.
Pros and Cons
All new posts will follow the new default category.
Old posts remain unchanged.
2. Using “Quick Edit” for Every Post
Another solution is to use Quick Edit to uncheck Uncategorized checkbox from posts one by one so as to delete Uncategorized from posts, but you will get tired if there’re still hundreds of post to go. The link location of “Quick Edit” is shown as below.
Pros and Cons
It will do exactly what we expect.
It’s very time-consuming and tedious.
3. Renaming Uncategorized
The quickest way to remove the term “Uncategorized” is to rename it permanently or temporarily. Because the term implies uncertainty for readers or subscribers, and you maybe want another more general term to represent your posts instead. The better thing is that you can change its slug as well.
Let’s see the list of posts before we change the name of “Uncategorized”. As you can see, the posts are all “Uncategroized” at this moment.
Here are steps to rename it:
- Go to Categories page
- Search for “Uncategorized” category
- Rename its name and slug
Please click on Categories in Posts to get in the page.
There should be only one row to be found. Under the name, a link called Quick Edit is what we are looking for.
In this case, we rename them as “Blog” which is a very general term that can be widely used among posts, then we click Update Category.
Let’s see the post list again. We have changed all “Uncategorized” into “Blog”.
Pros and Cons
The undesired name has been changed into a general or meaningful term as you wish for all posts in seconds.
Basically, we have not deleted the native category. We just replaced a name for it.
4. Deleting Rows From Tables Directly
I have a trick that can break all relationships between posts and categories just in two SQL statements so as to delete Uncategorized from posts. You can execute the SQL statements by tools like phpMyAdmin or any other interfaces that can help connect to your MySQL database.
That is to say, you must have the right to access your database and know some knowledge about SQL execution.
Suppose your table prefix is wp_blog_, please execute the following SQL statements.
delete from wp_blog_term_relationships where term_taxonomy_id = 1 and object_id in (select id from wp_blog_posts where post_type = 'post' and post_status = 'publish');
This statement will cut off the relationship between your posts and Uncategorized, its term_taxonomy_id is always 1.
Please note that I only target the posts with status publish in the above SQL statement. If you want to target all posts, you can modify the statement to fit your needs.
Next, we reset the statistics of term Uncategorized to 0.
update wp_blog_term_taxonomy set count = 0 where term_taxonomy_id = 1;
The column count is the number of posts or pages that belongs to this category. Given our situation, we set it as 0 which means no published post is under Uncategorized now.
Pros and Cons
We can delete Uncategorized from posts in seconds.
You must have the right to connect MySQL and some knowledge about executing SQL statement.
Don’t mistake the table names in above example codes. You have to use your own WordPress table prefix to replace mine (i.e. wp_blog_) in order to correct the table names in the statements before executing them. Otherwise, you will get the error like this:
ERROR 1146 (42S02): Table ‘database_name.table_name’ doesn’t exist
Finally, let’s check the result.
As you can see, the posts now show “—” which means no category is related to them and we have deleted Uncategorized from posts. Now, you can use Bulk Actions -> Edit to set proper categories for these posts.
5. Bulk Actions Edit
The following approach does not work. It’s only for your reference.
There’s a function called Bulk Actions in post list that can let you edit some attributes of checked posts at the same time. Therefore, we take advantage of it to add one or more categories to posts that belongs to no category.
Please note that, If you are thinking this method can be a solution to our problem, you will be disappointed because it can only add categories from posts, NOT remove.