Adding categories to pages in WordPress

Kyle van Dusen described how to do this in his video about setting up a starter site. He used categories to define “standard pages” – pages for things like Terms &Conditions, Privacy Policy, etc., that didn’t need featured images.  

I never had a need for it until I got started on the Holy Comforter website where we’re using a full-width hero on pages. I didn’t want to bother with the hero and image on the policy pages, so I went looking for Kyle’s video.

Kyle showed the code he used, but it was difficult to read on screen. So after reviewing the video, I did a search for “wordpress add categories to pages” and found several articles that offered a simple line snippet:

function register_category_and_tag_with_pages(){
    register_taxonomy_for_object_type(‘category’, ‘page’);
    register_taxonomy_for_object_type(‘post_tag’, ‘page’);
}
add_action( ‘init’, ‘register_category_and_tag_with_pages’);

I added that code to the functions.php file of the child theme and now get a metabox when editing a page.

When I create the hero element, I’ll exclude it from standard pages.

Total time, including finding the code, adding it, testing it, and writing this post is about 90 minutes.

Leave a Comment