mtekk / Breadcrumb-NavXT

The longest maintained Breadcrumb plugin for WordPress
https://mtekk.us/code/breadcrumb-navxt
51 stars 25 forks source link

Fix How Non-Hierarchical Taxonomies Are Handled #230

Closed mtekk closed 4 years ago

mtekk commented 4 years ago

The current mess that is post_terms() is not compatible with the JSON-LD output functions. Should check if there is only a single term, if so, use the normal/hierarchical code path. Ideally, post_terms() will get deprecated.

mtekk commented 4 years ago

For now, we're going to jump over to the hierarchical path if there is only one term (which makes the most sense for that specific situation). Long term, either need to implement a cleaner second dimension in the core of the plugin so that the assembler doesn't have to deal with pre-assembled junk in the title, or deprecate this term type for breadcrumb trails (honestly, hierarchical terms are more specif and better suited for a location breadcrumb trail).

mtekk commented 4 years ago

The most correct way of viewing this seems to be acknowledging that there is an implied second dimension to the breadcrumb trail when a member of multiple terms (especially true when in the same taxonomy). Traditionally, this has been handled poorly for non-hierarchical terms (explicit expansion of the dimension for said breadcrumb). For hierarchical terms, we always tried to pick the "most correct" term. Ideally, we'd collect everything in a multi-dimensional array and change how display_loop works to handle having arrays in the breadcrumbs array.

While this will improve flexibility, it will not actually fix the JSON-LD issue (there does not appear to be facility within BreadcrumbList to support itemListElement arrays within the itemListElement array). Ultimately, we need to pick a term. Luckily, there is already the bcn_post_terms filter, we could pick the first term and pass that into the filter. This will force the single term (term_parents), JSON-LD compliant, code path. If the user want's to override that, they can rerun get_terms in their filter and return them.

mtekk commented 4 years ago

Rather than change the behavior for 6.5, an article will be provided on using bcn_post_terms to return a single term so that the generated breadcrumb trail is JSON-LD compatible.

mtekk commented 4 years ago

Article written and scheduled for 2020-05-15.