Wordpress

How to Delete Uncategorized From Posts in WordPress

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.

  1. Rating 2 Stars   Changing “Default Category”
  2. Rating 3 Stars   Using “Quick Edit” for Every Post
  3. Rating 4 Stars   Renaming Uncategorized
  4. Rating 5 Stars   Deleting Rows From Tables Directly
  5. Rating 0 Star   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.

  1. Use your mouse to hover Settings > Writing in /wp-admin.
    Wordpress Settings Writing
    WordPress Settings Writing
  2. Select anyone you like for your default category.
    Wordpress Default Post Category
    WordPress Default Post Category

Pros and Cons

  • Pros
  • All new posts will follow the new default category.

  • Cons
  • 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.

Wordpress Quick Edit Link
WordPress Quick Edit Link

Pros and Cons

  • Pros
  • It will do exactly what we expect.

  • Cons
  • 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”.

Wordpress Change Uncategorized Name Before
WordPress Change Uncategorized Name Before
As you can see, the posts are all “Uncategroized” at this moment.

Here are steps to rename it:

  1. Go to Categories page
  2. Please click on Categories in Posts to get in the page.

    Wordpress Categories Page
    WordPress Categories Page

  3. Search for “Uncategorized” category
  4. There should be only one row to be found. Under the name, a link called Quick Edit is what we are looking for.

    Wordpress Search Uncategorized
    WordPress Search Uncategorized

  5. Rename its name and slug
  6. 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.

    Wordpress Quick Edit Uncategorized
    WordPress Quick Edit Uncategorized

Let’s see the post list again.

Wordpress Change Uncategorized Name After
WordPress Change Uncategorized Name After
We have changed all “Uncategorized” into “Blog”.

Pros and Cons

  • Pros
  • The undesired name has been changed into a general or meaningful term as you wish for all posts in seconds.

  • Cons
  • 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

  • Pros
  • We can delete Uncategorized from posts in seconds.

  • Cons
  • 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.

Wordpress Remove Uncategorized from Posts
WordPress Remove Uncategorized from Posts

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.

Bulk Actions -> Edit
Bulk Actions -> Edit

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.

Leave a Reply

Your email address will not be published. Required fields are marked *