How To Add WordPress Category Extra Fields

WordPress doesn’t have a category or tag meta data table in it’s database. This could be done on any category or tag or custom taxonomy. In this tutorial, we will learn how to add extra category fields in WordPress.


First of all, we need to add the extra fields to the category form using the hook {taxonomy-name}_add_form_fields and we use a simple function that will print out the extra fields. {taxonomy-name}_edit_form_fields is for edit category form fields. We use the same function to add form fields and to edit form fields. Here the {taxonomy-name} can be our category name or tag name.

As you can see, we added new fields and all of them are in an array Cat_meta[key] because it is the only way to create one row in the options table to save all of the category’s extra fields instead of a row for each field.

Now we need to save the extra fields into the database once a user submits the category edit form and we do that using “created_{taxonomy-name}” with a function that will run through each of the submitted fields and insert them to the database using the update_option function like this.

edited_{taxonomy-name} is used to save the edited category form fields. We use the same function to save the newly created category fields and edited category fields.

From the code above, you can see that all of the extra fields we’ve added are stored in the database’s options table with the name ‘category_ID‘ , where ID is the id of that specific category we just edited and that means we can call this data in our plugins or theme files easily using the get_option function. For example, if my category ID is 25 then my code will look like the following:

User Comments

3 thoughts on “How To Add WordPress Category Extra Fields

    Ce says:

    Hi there,

    Can you explain me in which files do i need to insert each part of the code?

    Best regards

    Nam says:

    When we move to another host by creating new db and import this db, these extra data do not storage. Have you tried?

Leave a Reply

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

    Get in Touch