Greetings,
I’ve changed my archive pages to static pages with the PHP at the bottom here. (as suggested in this forum)
I’ve changed the canonical links to static URLs without the word ‘category’ in them, but they keep showing up as something like https://thegreatestsong.com/category/audio-gear-reviews/
What I would like is:
https://thegreatestsong.com/audio-gear-reviews/
I’ve obviously missed some key step here which removes category from the URL. Your help would be most appreciated.
Kind Regards
PHP snippet I’m using:
add_filter('request', function( array $query_vars ) {
if ( is_admin() ) {
return $query_vars;
}
if ( isset( $query_vars['category_name'] ) ) {
$pagename = $query_vars['category_name'];
$query_vars = array( 'pagename' => "$pagename" );
}
return $query_vars;
} );