## Adding Parent Categories and keep current URLs

Question

I have a website that contains 200 categories with thousands of words in on every category page. Most of these category pages is where my traffic comes from, and have the following URL structure: example.com/tennis-shoes/.

However, now I want to add parent categories in order to organize the content for my visitors, which means that the URL:s will be example.com/parent-category-name/tennis-shoes/. This will obviously have a major negative impact on my rankings and it’s therefor something I don’t want to risk.

I’ve done some research and testing and realized that I have 2 problems with this addition of parent categories, namely the website URLs and the sitemap URLs.

The sitemap URLs I’ve managed to change with the following code:

function sitemap_post_url( $url,$term, $object ) { // Remove the parent category slug from the URLs by replacing it with an empty string if (strpos($url, '/tennis-shoes/') !== false) {
return str_replace("/tennis-shoes/", "", $url); } return$url;
}
add_filter( 'wpseo_sitemap_entry', 'sitemap_post_url', 10, 3 );


As for the website URLs I don’t know what to do, maybe I need to add some kind of redirect hook/filter in functions.php – similar to the filter code above – so that the URL:s to my now child categories (since I’ve added parents) exclude the parent slug from the URL so it does not affect my current indexed URLs.

In short what I want to do is to organize my site with parent categories but keep all my current URLs so it doesn’t affect me SEO.

Hence, my questions are:

• How can I exclude the parent category slug for the website URLs, just
like I do for the sitemap URLs with the filter code?
• If I manage to
solve the above, will my SEO to my currently indexed categories (and
90% of my search traffic) be affected in a negative way by adding
these parent categories in order to improve the structure for my
visitors?
0
1 month 2022-07-01T15:33:37-05:00 0 Answers 0 views 0