How to achieve post hierarchical rewrites for custom post types (6 posts)

  1. Seldimi
    Posted 1 year ago #

    Hello everyone,
    Before I start my probelm, I'd like to say that I've searched over and over for months for a solution, I found some of them but didnt work exactly as I wanted to. I am an expericened developer, meaning I know most wordpress codex basic stuff... Let’s roll now

    I am having a custom post type "business" and a custom taxonomy "directory" (for a business directory website)

    I am trying to achieve rewrites URLs to

    I have tried the solutions with adding hierarchical to true, has archive to tax name, even the add_filter('post_type_link') with the %business$ stuff

    All I've managed is to get are these URLs:

    I need to get the hierarchical url work with the post type item like

    Can you guide me with the most proper way (and less risky in coding) of achieving this?

    Thank you

  2. ivantus
    Posted 1 year ago #

    Were you able to achieve this: /category/subcategory/if_any_more_subs/custom_taxonomy (in your case: category/subcategory/if_any_more_subs/directory) and if so - how?
    Basically I need the same you do but with custom tax also for a business directory website.

  3. Seldimi
    Posted 1 year ago #

    You may add on taxonomy rewrite hierarchical to true and its done

  4. ivantus
    Posted 1 year ago #

    This would only produce:

    but I need:

    I'm sorry for taking over your thread. Never mind and thanks for your assistance.

  5. Andrew
    Forum moderator
    Posted 1 year ago #

    I'm sorry for taking over your thread.

    Feel free to create a new thread discussing this.

  6. Seldimi
    Posted 1 year ago #

    I've came up to the end of the problem. The real problem is that you cannot get unlimited (or different size) for rewrite rules.

    Eg. you cant get a rewrite that says try if the last is post load this or else load that..
    I tried to follow the original "post" rewrites but they use /category/ slug as well (even yoast can ommit it, but it makes custom rewrites for each and every post category - which making it by hand is really difficult)

    So the only approach is making a rewrite rule same as post and then call in functions.php all the rules needed for making each category a separated rule...

Topic Closed

This topic has been closed to new replies.

About this Topic