Wordpress - show parent category and subcategory name in the URL of the subcategory archive

I'm having problems with the urls in the Wordpress category/subcategory .

For example, I want to be able to display this archive:
http://faroutmagazine.co.uk/wp/track-of-the-day by storing your parent category in the url, making it http://faroutmagazine.co.uk/wp/music/track-of-the-day

I used to get the message β€œThis is inconvenient ...” 404 when accessing the URL /music/track-of-the-day (even if the one that appeared in the β€œView” option under the categories in the WP admin section).

Now the View link in the administration area shows me only the URL /track-of-the-day , and that means the category posts are great, but I want it to include the parent category in the URL.

Is there anything I can do for the functions.php file or any plugins I can add to make this happen? Keep in mind that this site has several archives of subcategories, and they must contain the parent category in the URL.

*** UPDATE: Actually, I just set everything up differently, using pages and showing categories of archives on pages, as it takes too much time. Thanks for your reply. People telling me to use %category%/%postname% as the permalink structure is incorrect - yes, this works for POST URLs, but not for the subcategory archive category, which is the problem I was really looking for help with. If someone can give an answer, it will be appreciated, but I am using this workaround now, as it has been trying to figure out too much time.

+8
wordpress wordpress-plugin wordpress-theming
source share
8 answers

This is because when editing an entry you selected a category and a subcategory to the right of the checkmarks. Select only the subcategory field in each entry and it will display the sub URL.

+13
source share

For this to happen, you need to make some changes to permalinks.

go to Settings-> Permalinks , then select your own structure and use this syntax /% category% /% postname% / "in the field

Now save the settings and you can see the URL of the message using its category name in the permalink

Hope this helps :)

+5
source share

In fact, hierarchical subcategory files are always set by default in wordpress.

If you have a "good permalinks" structure selected in> permalinks settings, for example /%postname% , then the URLs of the category pages and subcategories should have a default value: yourdomain.com/category-base/category/sub-category/sub-sub-category

I ran into a similar issue with a recent WP project, BUT I used a plugin called WP No Base Permalink to get rid of my category and base slug tags in my permalinks. When I turned off the plugin, the category hierarchy suddenly returned to my permalinks in the archive (fortunately, this project was still under development, otherwise I would have 404 main problems).

I have not yet found / tested another plugin to eliminate the basic slug-systems of category / tags, which will also save the hierarchy in the URLs of the sub / category archive, but it turns out that I do not need this functionality for my current project.

Instead, I use the basic slugs blog-articles and blog-tags for standard categories and tags to establish blog taxonomies, among other taxonomies. Then I use the Types plugin to create a custom post type and custom taxonomies for this post type. The Types plugin has an option in the advanced settings for setting hierarchical taxonomic URLs true or false when creating a custom taxonomy.

Finally, I found a plugin called Remove Taxonomy Base Slug , which effectively excludes the default taxonomy term from the base pool of taxonomy archive URLs. And this, fortunately, does not interfere with the sub / category hierarchical attributes, or base bullets for standard tags and categories.

So my blog categories / tags are as follows:

yourdomain.com/blog-articles/category/sub-category/ or yourdomain.com/blog-tags/tag/

And my custom categories / message type tags look like this:

yourdomain.com/category/sub-category/ or yourdomain.com/tag/

Phew!

Hope this helps!

+3
source share

Settings settings-> Permalink-> Base category to "% category%" should provide you with what you want. According to WP document:

Sub-categories are displayed as sub-directories in the URI

See http://codex.wordpress.org/Using_Permalinks .

+2
source share

Permalinks parameters should be like /% category% /% postname% / ..

+1
source share

If you use custom permalink options like% postname%, this will make your URL look like ... / category / subcategory.

0
source share

You can use the WordPress plugin to remove a category from the URL http://wordpress.org/plugins/wp-no-category-base/ and then follow the instructions given by Maruti

0
source share

You must set the hierarchical value to true when you define your taxonomy.

'rewrite' => array('slug' => 'mySlug', 'hierarchical' => true),

Then, if you have a subcategory, the url will be displayed as follows: 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

0
source share

All Articles