I'm having some trouble with Wordpress category/subcategory
archive URLs.
For example, I want to be able to display this archive:http://faroutmagazine.co.uk/wp/track-of-the-day
while keeping its parent category in the URL, making it http://faroutmagazine.co.uk/wp/music/track-of-the-day
Previously, I was just getting a "This is embarrassing..." 404 message when accessing the /music/track-of-the-day
URL (even though that's the one that was appearing in the View option under categories in the admin section of WP).
Now the View link in the admin area only shows me the /track-of-the-day
URL, and this DOES display the category posts which is great, but I want it to include the parent category in the URL.
Is there anything I can do to the functions.php
file or any plugins I can add to make this happen? Please bear in mind that there are multiple subcategory archives on this site, and they should all contain the parent category in the URL.
***UPDATE:
I actually have just set everything up a different way now using Pages and showing category archives on pages as it's taking up too much time. Thanks for your answer though. People telling me to use %category%/%postname%
as the permalink structure are incorrect - yes, this works for the POST urls but not for the archive category of the subcategory which is the problem I was actually looking for help with. If anyone can provide an answer, it would be appreciated, but I am using this workaround now as this was taking up way too much time trying to figure out.
In the sidebar, go to Appearance → Widgets, then choose the categories that you want to appear in the sidebar and click Add Widget. When you want to show subcategories in the sidebar, drag and drop categories to a Sidebar. Then check the box next to Show hierarchy in categories widget's settings and click Save.
Adding a Child Category (Sub Category) in WordPress Then select the category that you want to use as the parent from the dropdown list. Similarly, you can also go to Posts » Categories to add child categories. Just type in the name for your child category and select the parent category from the dropdown menu.
To show WordPress permalinks as category/subcategory/post go to Settings > Permalinks. Choose 'Custom Structure' and add /%category%/%postname%/ to the field. Now if you add one category and one subcategory, WordPress will show both of them in the permalink.
You should set hierarchical value to true when you are defining your taxonomy.
'rewrite' => array('slug' => 'mySlug', 'hierarchical' => true),
Then if you have a subcategory the url will be shown like this: http://example.com/taxonomy/parentCategory/subCategory/
I found this sloution here:
https://wordpress.stackexchange.com/questions/155319/how-to-include-parent-terms-in-hierarchical-taxonomy-urls
This happens because you chose category and subcategory from the right options tick boxes when editing the entry. Choose only the subcategory box in every entry and it will show the nested URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With