Last week, I was playing around adding categories to my WordPress pages, that’s because I started to increase the number of pages in one of my sites and it was starting to be difficult to organize the content there. In particular, I wanted to group all my terms and legal pages under a “Terms” category, my about and contact page under another category and so on.
So I find a way to use my post categories across my pages too. All you have to do is to add the following code in your functions.php file.
1 2 3 4 5 6 7 8 9 10 11 |
//Add categories to Pages function add_taxonomies_pages() { // This code add the metabox for tags to Edit Page register_taxonomy_for_object_type('post_tag', 'page'); // This code add the metabox for categories to Edit Page register_taxonomy_for_object_type('category', 'page'); } // This code add the admin options to the admin_init hook add_action( 'init', 'add_taxonomies_pages' ) |
This way you should be seeing the “Categories” menu under the “Pages” section in your admin area and also the metaboxes to assign categories and tags when editing a page in your right sidebar.
Note that this code will share the categories of your posts with your pages. But you can just create those one you need for your pages and not use them for posts and viceversa, it wasn’t a problem for me at least.
I hope you find this useful too. If you did, leave me a comment 🙂