0

I've created two custom post types with some custom hierarchical taxonomies. In the navigation a link to the custom post type is displayed. When clicking on it, the user is forwarded to a page that displays the highest level hierarchical terms. He is now free to choose one and is then forwarded to a second page that shows the child terms of the taxonomy he clicked on. He can now choose one of these terms and is then forwarded to an archive page that displays all the articles of these categories.

For a better user experience I think it is essential, to tett the user where he is on the site. And therefore I want to implement a breadcrumb. My breadcrumb works so far, but I have no idea how to show the correct path within posts.

Lets say there is a post named Post 1 inside the custom post type My Posts that is categorized with the terms Parent and Child.

How can I code the breadcrumb out so that it says:

Home / My Posts / Parent / Child / Post1

This should all work automatically. If a post has the term Child2 insted of Child the breadcrumb should adapt. And if there are no child terms but only a parent term, it souldn't display a blank child term.

I hope you understand what I want to get.

Thank you very much in advance!

  • Breadcrumbs can be a lot of logic, which you can grasp if you look at any existing plugin. What is your question here? For someone to write breadcrumbs from scratch? That scope is too wide. I would recommend to break this up into smaller and more specific issues. You don't know how to retrieve post parents? Start with asking about that, and so on. – Rarst Aug 24 '16 at 17:10
  • @Rarst To be able to split the question up, I need an idea on how to achieve my goal. After having an idea on how to solve the problem, I can tell you which parts I can't code myself. But at this point I'm only standing in front of the problem without having an idea on how to solve it, so I can't split the questions up. Would you mind giving me a short explanation how you would code this out? – Sam Aug 24 '16 at 17:36
  • (1) enumerate every part I want in breadcrumb in each case, (2) figure out how to retrieve those parts starting with data I have, (3) figure out how to put them in meaningful order. (4) output result. – Rarst Aug 24 '16 at 17:42
  • @Rarst Okay, thank you. Well how would you extract the parent term and – if available – the child term? – Sam Aug 24 '16 at 21:32
  • That would be a good separate focused question, not a comment discussion. :) – Rarst Aug 24 '16 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.