• I have been looking for a solution for quite a while. Googling, I get a lot of ideas, but none of them work as they should.

    What I want:
    domain.com/own-cpt/ <- archive of all posts of own cpt (custom post type)
    domain.com/own-cpt/taxonomy1/ <- archive of the taxonomy
    domain.com/own-cpt/taxonomy1/taxonomy-sub/ <- if there is a child taxonomy … show all posts of the child

    domain.com/own-cpt/taxonomy1/taxonomy-sub/taxonomy-sub-sub/slug-of-post/ <- show the post

    So all the cats and subcats should be in the url (if they exist).
    To have a primary url I use yoast with the primary category.

    Using:
    YOAST Primary Category
    Own Custom Post type
    Own Taxonomy

    Is there a reliable and understanable way to solve this?

    Thanks a lot and have a nice weekend.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You might want to ask at the support forum for the plugin you use for Primary Category, since they know best what it does.

    Without that in the mix (since I don’t know it), by default WordPress will have
    domain.com/own-cpt/ <- archive of all posts of own cpt (custom post type)
    domain.com/taxonomy1/ <- archive of the taxonomy (this can’t have the cpt in it or it would be mistaken as an archive of the cpt, and taxonomy can be shared)
    domain.com/taxonomy1/taxonomy-sub/ <- if there is a child taxonomy … show all posts of the child

    The address of the cpt post in a child term of the taxonomy depends on the parameters given to register_post_type, and could be affected by your category plugin. Look at https://developer.www.ads-software.com/reference/functions/register_post_type/ where it describes the ‘rewrite’ parameter.

    Moderator bcworkz

    (@bcworkz)

    You can get WP to recognize unusual link structures with add_rewrite_rule().
    https://developer.www.ads-software.com/reference/functions/add_rewrite_rule/

    The challenge in adding rewrite rules is coming up with the right regexp that’ll match the correct situations without incorrectly matching other unrelated links. In general, the more specific the matching criteria is, the better. Matching one particular taxonomy slug is better than trying to match all possible taxonomy slugs. Of course some portion of the link has to be variable. That’s fine, capture it only when there are other specific, unvarying matches in the link.

    Thread Starter flaschenzug22

    (@flaschenzug22)

    thanks, that helps already :-).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CPT and taxonomy with hirachical URL ?’ is closed to new replies.