When setting up the ‘blog’ section of my WordPress website for the first time, I came across an issue. For some reason, archive pages for my child category were not appearing underneath the parent-category/child-category permalink path.
Instead of posts from the child category Facebook, I was greeted by a 404 page not found when I visited archive page seosteph.co.uk/social-media/facebook/ .
However, if I navigated to the child category as though it was a parent (i.e. no parent category proceeding it in the permalink – e.g. seosteph.co.uk/facebook/ instead of seosteph.co.uk/social-media/facebook/) then the archive page displayed the posts belonging to the child category. “That’s not right!”, I thought.
I could understand this if my permalink structure didn’t include the parent category ahead of the child category, but it did. Even the category meta tags on my posts pointed to the archive page under the parent/child hierarchy.
When setting permalinks for my posts page through WordPress, I had used Custom Structure with /%category%/%postname%/ setup so that I could have a nice hierarchy to my URLs and it worked fine.
To further enhance my URLs, I used a dot (.) in the optional Category Base fields of the Permalinks settings to strip out the prefix ‘category’ that proceeds any category name in the permalink structure of WordPress posts by default. e.g. with the dot, seosteph.co.uk/category/social-media/facebook/ became seosteph.co.uk/social-media/facebook/
However, I discovered it was the implementation of the dot in the Category Base, to rid the prefix in the category permalink, that was causing my archive pages not to resolve as they should.
By removing the dot from the Category Base so the field is kept blank (as it is by default), and enabling Strip Category Base in the Links section of Rank Math plugin instead, the archive pages for my child category correctly appeared under the /parent-category/child-category/ structured URL. There’s a similar option available in the Yoast SEO plugin to get rid the category prefix under Search Appearance > Taxonomies settings called ‘Remove the Categories Prefix‘.
I hope this helps anyone who may have come across this issue and was left scratching their head as to why their child category, following their hierarchy parent/child category permalink structure, was not displaying posts on their child category archive page.
0 Comments