How to add Categories to Pages in WordPress

If you build sites using WordPress as a CMS you might have wanted to add categories to pages.

Well, look no more, here's the snippet that will save your life 🙂

Paste the following code into your functions.php file of your theme and you're set.

Notice you can also add categories to any custom post type you might have created.

function my_function_name() {  
	register_taxonomy_for_object_type('category', 'page');
       /* Any custom post type*/  
	//register_taxonomy_for_object_type('category', 'my_custom_post_type');  
add_action( 'admin_init', 'my_function_name' );

About Ricard Torres

Senior Front-end Software Engineer from Barcelona, Haidong Gumdo Instructor (korean martial art of the sword), street photographer, travel lover, TV addict, Boston Red Sox fan, and privacy advocate.

@ricard_dev @ricard_dev

📝 Blog 🎙 Podcast

Leave a Reply

Add <code> Some Code </code> by using this tags.