I’m looking for a way to delete default category functionality in wordpress but after i delete the default category in wp_terms
table in mysql database, it automatically assigns default category to another category.
Does anyone know how to achieve this?
Thank you for any help.
Impossible. WordPress requires a default category, thatâs hard coded.
If you need a taxonomy without default value â create a custom taxonomy.
Solution:
This is a very old question but I had a similar requirement and I found a way to do it.
Why the above code will work?
This will give empty string to WordPress when it’s trying to set default category on post save here: https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L3672-L3680
Later it will try to assign that category here: https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L3955-L3957
and that function will return true from elseif since category array is not empty but value is empty in here https://github.com/WordPress/WordPress/blob/7004afe4f4bac1fd17a142051832bdf6be8e6fcf/wp-includes/post.php#L4613-L4622
Note, user will see option to set default category in
wp-admin/options-writing.php
this code does not disable that but that functionality won’t work anymore.I was able to achieve this by manually removing the record in the database, if I recall correctly it was located in wp_terms but I could be wrong.
The easy way to do it is to go to your table ‘wp_options’ and set ‘default_category’ to 0.
I can’t understand why people keep saying that a term is an absolute requirement of WordPress. It’s not.
If nothing else, you can change the default category from “uncatogorized” to “news” or something relevant for your use.