A nice simple way to be able to add Category and Tags to pages without a plugin. Now you can add a category which is usually only available in post pages.
Add this to your functions.php file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function add_taxonomies_to_pages() { register_taxonomy_for_object_type( 'post_tag', 'page' ); register_taxonomy_for_object_type( 'category', 'page' ); } function category_and_tag_archives( $wp_query ) { if( $wp_query->is_main_query() && ! is_admin() && ( $wp_query->is_category() || $wp_query->is_tag() )) { $my_post_array = array('post','page'); if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) ) $wp_query->set( 'post_type', $my_post_array ); if ( $wp_query->get( 'tag' ) ) $wp_query->set( 'post_type', $my_post_array ); } } add_action( 'init', 'add_taxonomies_to_pages' ); add_action( 'pre_get_posts', 'category_and_tag_archives' ); |