Skip to main content

How to disable Default Post Category in WordPress?

The best way of removing default category is to change a parameter is to change the parameter ‘default_category’ in your ‘wp_options’ table.

Set the parameter ‘default_category’ to 0. Note that it won’t change the category displayed in your dashboard in the Writing settings, but it will prevent WordPress to set a default term to your post.

WordPress doesn’t require a term or category to be set by default. It’s just not true 😉

Note that this trick, setting the parameter ‘default_category’ to 0 will let you delete Uncategorized category if it bothers you.

 

I can provide you with a simple WordPress plugin that will change the default_category parameter in the wp_options table to 0. This will allow you to delete the “Uncategorized” category if desired.

Here’s a step-by-step guide to create the plugin:

  1. Create a New Plugin Folder: Navigate to your WordPress installation’s wp-content/plugins/ directory and create a new folder named remove-default-category.
  2. Create the Main Plugin File: Inside the remove-default-category folder, create a file named remove-default-category.php.
  3. Add the Plugin Metadata and Code: Open remove-default-category.php in a text editor and add the following code:
php
<?php
/*
Plugin Name: Remove Default Category
Description: Changes the 'default_category' parameter in the 'wp_options' table to 0, allowing the deletion of the "Uncategorized" category.
Version: 1.0
Author: ChatGPT
*/
// Hook into WordPress’ activation hook to run our function when the plugin is activated
register_activation_hook(__FILE__, ‘remove_default_category_function’);

function remove_default_category_function() {
// Update the ‘default_category’ option to 0
update_option(‘default_category’, 0);
}
?>

  1. Activate the Plugin:
    • Log in to your WordPress dashboard.
    • Navigate to the Plugins page.
    • You should see a new plugin named “Remove Default Category”. Activate it.
    • Once activated, the plugin will automatically set the default_category parameter to 0.
  2. Deactivate and Delete: If you ever want to revert this change, simply deactivate and delete the plugin. However, remember to manually set a default category in the WordPress Writing settings afterward.

Note: Always backup your WordPress database before making any changes or activating new plugins. This ensures you can restore your site in case of any unforeseen issues.

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *