August 13, 2017 php Wordpress 0

As a default, WordPress won’t allow you to categorise the pages, as it only allows categories to be set to posts. The good news is that there is a very easy way to enable categories to WordPress pages. Just paste the code below into your plugin’s or theme’s functions.php file, and you’re done:

1
2
3
4
5
function add_taxonomies_to_pages() {
 register_taxonomy_for_object_type( 'post_tag', 'page' );
 register_taxonomy_for_object_type( 'category', 'page' );
 }
add_action( 'init', 'add_taxonomies_to_pages' );