最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

permalinks - Using 'Primary Category' in URL

programmeradmin4浏览0评论

I'm running into an issue where I want to set up categories in my URL (%category%/%postname%), but doing this will create multiple URLs for the same content if I select multiple categories.

So, for example, if I put a 'Bugatti' post in the 'cars' and 'supercars' categories, the 'Bugatti' post will be available at both 'mysite/cars/bugatti' as well as 'mysite/supercars/bugatti'.

I want to restrict this to where the content will only be available for the primary category that I select. So if I select the category 'supercars' as my primary category, the post 'bugatti' will only be available at 'mysite/supercars/bugatti' and any secondary category URLs ( i.e. 'mysite/cars/bugatti', etc. ) would return a 404. Is there any way to do this using the 'primary category' from Yoast or otherwise?

I noticed that Wirecutter does this for their site. They're running WordPress, using a %category%/%postname% permalink structure, but any of their secondary categories in the URL only return a 404.

Thanks for any help you can provide!

发布评论

评论列表(0)

  1. 暂无评论