I have problem with wordpress rewrite and SEO, mostly the sitemap. I'm using the Yoast SEO plugin.
I use the regular "post" post type with two taxonomies. The regular "category" and a cutom taxonomy called "city".
register_taxonomy('city', 'post', array( 'hierarchical' => true, 'show_admin_column' => true, 'query_var' => 'city', 'rewrite' => array( 'slug' => 'city', 'with_front' => true, 'hierarchical' => true ) ));
This leads to the
taxonomy-city.php file. No problem so far. But I wanted to create a cutom url, which has both taxonomies, like:
$wp_rewrite->add_rule( 'city/([^/]+)/([^/]+)/?$', 'index.php?city=$matches&cat=$matches', 'top' );
Which makes this request also load the
taxonomy-city.php file. Everything was working, but when I checked the seo titles, canonical tags and the sitemap, they dual category pages are not recognized as a separate page, just the same as the
/city/some_city/ url. I solved the canonical tag and meta tag problems, but the sitemap is a bigger problem, because they are missing from the sitemap.
I see two possible solutions, couldn't make any of them work.
- One of them is that I add new entries to the sitemap, but couldn't find any hook to do this.
- The other one is, that I make wordpress somehow recognize this combination as a regular page. Perhaps make a connection between the two taxonomies.
I tried a lot of things, for example sending the redirect to the
category.phpfile or adding a permastruct to the city taxonomy containing the category as well. Nothing seems to work.
Can someone give me a hint, at least which path should I go forward or am I missing something obvious here? Thanks.