This plugin will allow you to assign categories to pages
https://wordpress.org/plugins/category-tag-pages/
but it will not display them on the page. You’d have to modify the page.php template for your theme to do it.
Thread Starter
Alkorr
(@alkorr)
Hi Steve, thank you. But I already installed a plugin to add Categories to Pages and it doesn’t do what I want, even if I add the Categories, the permalink of the page will still be :
myblog.com/concerts
and not:
myblog.com/category/music/rock/concerts
Did you set permalinks to include categories? Also, have you asked a question in that plugin’s support area?
Thread Starter
Alkorr
(@alkorr)
I didn’t use a Plugin (I installed one and then removed it) because I preferred to add some code to my functions.php.
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' );
if ( ! is_admin() ) {
add_action( 'pre_get_posts', 'category_and_tag_archives' );
}
function category_and_tag_archives( $wp_query ) {
$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 );
}
It works fine but unfortunately, the permalink doesn’t work like I would like.
And yes, I set up my permalinks to include categories:
/%category%/%postname%/
I tried to use .htaccess to redirect:
myblog.com/concerts
to:
myblog.com/category/music/rock/concerts
But it doesn’t work neither… 🙁
The permalink settings, I think, refer only to posts. You may need to create custom redirect rules for caategorized pages.
Thread Starter
Alkorr
(@alkorr)
Steve, I think you’re right, indeed… So I tried to redirect the page via .htaccess but it doesn’t work.
I thought it could be easy to do but now I think I’m stuck <:)