How to Enable Categories & Tags in Pages (WordPress)
In today’s article, I’m going to show you how you can enable the category section inside your pages.
As you know, WordPress only allows assigning categories inside the post section by default. But you can enable categories in the pages section, or you can also enable tags in the pages section so that:
- You can use filters
- You can categorize them
- You can categorize your pages and use them in different post grids or templates
So let’s check how you can enable that.
Two Options to Enable Categories and Tags in Pages
You have two options:
- Use a plugin
- Use a custom code snippet
Most people will install a plugin like “Pages with Category and Tags”.
- It has around 60,000+ active installations.
- But you don’t need a plugin to enable a simple setting in WordPress.
Using a Custom Code Snippet (Recommended)
All you have to do is just copy a code snippet like this.
Steps:
- To enable categories, let me copy this code snippet.
- I will go to my WordPress dashboard.
- Here you can use any code manager plugin.
- As you can see, I’m using the Code Snippets plugin.
Add the Snippet:
- Click on Add New
- Paste the PHP code
- Set the title like: Category in Pages (to remember this code)
- Click on Activate
Code Snippets
✅ Enable Category on Pages
add_action( 'init', 'add_categories_to_pages' );
function add_categories_to_pages() {
register_taxonomy_for_object_type( 'category', 'page' );
}
✅ Add Tags to WordPress Pages
function add_tags_to_pages() {
register_taxonomy_for_object_type('post_tag', 'page');
}
add_action('init', 'add_tags_to_pages');
✅ Use This Single Code for Both Categories and Tags
function add_categories_and_tags_to_pages() {
register_taxonomy_for_object_type('post_tag', 'page');
register_taxonomy_for_object_type('category', 'page');
}
add_action('init', 'add_categories_and_tags_to_pages');
What Happens After Activation?
After that, it will enable categories in the pages section.
- Click that
- Now you will see the category option in the pages as well
- If you click here, you will see all the categories
Assigning Categories to Pages:
- Click on Pages
- Suppose I want to assign some of the pages a category:
- Select all these pages
- Click on Edit
- Click on Apply
- Choose a category (e.g., Service)
- Hit Update
- As you can see, all these pages are now linked to the Services category
This is how we can enable categories in WordPress inside pages.
You Can Also Enable Tags
You can also enable tags.
- All you have to do is copy a code like this
- Just edit the previous snippet
Steps:
- Click on Edit
- Hit Enter
- Update the name to something like: Category and Tags
- Click Save Changes
Now let’s go to the Pages section again. Now you can see the Tags option is coming in Pages as well, so you can assign a tag in pages too.
Conclusion
This is how simple it is to assign categories and tags inside pages.
If you found this article helpful, don’t forget to hit the like button. You will get the link of this code snippet in the description, or you can also use a plugin to do that.
I will see you in the next one. Thank you!