I have been trying to solve this problem for hours. I would like to have a page with a simple slug (/blog) and a category term with the same name (/category/blog) exist on my site together at the same time. But the problem I am running into is that my page (/blog) keeps redirecting to the category archive page (/category/blog).
I have tried the following:
- adjusting my permalinks by clearly specifying my category base
- using remove_action('template_redirect', 'redirect_canonical'); to suppress redirects
- using add_filter( 'template_redirect', 'blog_redirect_filter', 10, 3 ); to try and target my blog category specifically
I am running out of ideas. How can I stop my site from redirecting an existing page to a category archive when they each have different slugs?
EDIT
I figured it out! Classic wait-until-you-post-publicly-before-figuring-it-out-yourself problem. It was a fun mix of Yoast, custom permalinks, and category bases all conflicting with each other.
My answer:
- Make sure your category base is specified in Permalinks. Save them.
- Remove any custom permalink slugs in the category terms.
- Go to Yoast > Search Appearance > Taxonomies and scroll to the very bottom. Make sure Category URLs is set to Keep.
- Clear any cache and/or flush_rewrite_rules.
- Voila it's fixed.