-
Dear support,
we have an issue which directly correlates with SEO and site / URL structure, which occurred after updating RankMath.
We run a recipe site which has multiple categories.
If you like to understand the issue better, you can visit https://rezepte-mix.de
Before the initial update, RankMath correctly selected the “primary” category on every recipe, which was always “rezepte”. Every recipe we had, could be found under rezepte-mix.de/rezepte/name-of-recipe to keep the URL-structure simple and clean, as we run a blog on the site in parallel. /blog/name-of-article
After the update, the whole site structure broke and every recipe which had multiple sub-categories shows this in the URL now, although the “primary” category “rezepte” is still activated.
Before: rezepte-mix.de/rezepte/name-of-recipe/
Now: rezepte-mix.de/rezepte/desserts/name-of-recipe/ (this is wrong)Yes, every recipe does have the primary and a sub-category, but the “primary term” doesn’t work anymore for whatever reason. The problem is that all of our recipes are indexed now under the wrong URL structure, which is a pity.
Unfortunately, I couldn’t resolve the issue myself. This is not a caching-issue.
The permalink-structure on WordPress is also correct: /%category%/%postname%/
The site runs on the “Kadence Theme”, however, I couldn’t find someone on their support-site who experienced the same issue.
Thank you for any help in advance and a happy new 2025!
PS: I even tried forcing the “primary category in URL” running a code-snippet using PHP but it didn’t work too. Here is the code snippet I used:
————–
function force_primary_category_in_permalink( $permalink, $post ) {
if ( strpos( $permalink, ‘%category%’ ) === false ) {
return $permalink;
}$categories = get_the_category( $post->ID );
if ( $categories ) {
$primary_category_id = get_post_meta( $post->ID, ‘rank_math_primary_category’, true );
if ( $primary_category_id ) {
$primary_category = get_category( $primary_category_id );
$main_category = $primary_category ?: $categories[0];
} else {$main_category = $categories[0];
}$permalink = str_replace( ‘%category%’, $main_category->slug, $permalink );
}return $permalink;
}
add_filter( ‘post_link’, ‘force_primary_category_in_permalink’, 10, 2 );————–
—
Kind regards
Alexey
The ticket ‘Issues with primary category + URL structure after update’ is closed to new replies.