get_category_link generating incorrect url including /blog/
Recently ran a SEO audit tool on the blog just to find out that all the category links were leading to 404s. Upon close inspection the URLs appeared to contain a /blog/ in them while the actual working URLs would be without it. See below:https://startdebugging.net/blog/category/opinion/
– not workinghttps://startdebugging.net/category/opinion/
– working
Apparently the whole issue was cause by the fact that I was using a custom permalink format for the posts which used /blog/ as a base and was being picked up by the category URLs as well.
How to fix it?
Make sure to specify a “Category base” in your permalink settings (Settings > Permalink), in my case I just set it to “category”.