WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Seldimi
    Member
    Posted 9 months 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
    directory/category/subcategory/if_any_more_subs/business

    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:
    directory/only_one_category/business
    directory/category/subcategory/if_any_more_subs

    I need to get the hierarchical url work with the post type item like
    category/subcategory/if_any_more_subs/business

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

    Thank you

  2. ivantus
    Member
    Posted 9 months 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
    Member
    Posted 9 months ago #

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

  4. ivantus
    Member
    Posted 9 months ago #

    This would only produce:
    /custom_taxonomy/custom_taxonomy_sub/custom_taxonomy_more_subs

    but I need:
    /category/subcategory/custom_taxonomy

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

  5. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 9 months ago #

    I'm sorry for taking over your thread.

    Feel free to create a new thread discussing this.

  6. Seldimi
    Member
    Posted 9 months 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...

Reply

You must log in to post.

About this Topic