bcn_default_hierarchy_display

This filter is applied within the breadcrumb_navxt class in the find_posttypes() function. It provides a method to override the default hierarchy display choice for custom post types. This filter was introduced in version 6.0. It receives three parameters:

  • $default_hierarchy_display(boolean)(required) The default choice to either display or not display a hierarchy for the custom post type
  • $post_type(string)(optional) The name of the post type that the default hierarchy type applies to
  • $hierarchy_type(string)(optional) The hierarchy type (BCN_DATE, BCN_POST_PARENT, or a valid taxonomy name) that Breadcrumb NavXT is going to use as the default for the custom post type

bcn_default_hierarchy_type

This filter is applied within the breadcrumb_navxt class in the find_posttypes() function. It provides a method to override the default hierarchy type for custom post types. This filter was introduced in version 6.0. It receives two parameters:

  • $hierarchy_type(string)(required) The hierarchy type (BCN_DATE, BCN_POST_PARENT, or a valid taxonomy name) that Breadcrumb NavXT is going to use as the default for the custom post type
  • $post_type(string)(optional) The name of the post type that the default hierarchy type applies to

Using bcn_display_json_ld()

bcn_display_json_ld is a display function for Breadcrumb NavXT that generates Schema.org BreadcrumbList compliant JSON-LD markup. It will generate a breadcrumb trail for the current page (resource, not post type). The following is the function’s prototype

bcn_display_json_ld($return = false, $reverse = false, $force = false)
  • $return the first parameter, it is a boolean and controls whether or not the breadcrumb trail is returned or echoed. Set to true to return the assembled breadcrumb trail string. It defaults to false if no value is passed in.
  • $reverse the third parameter, it is a boolean and controls the order the breadcrumbs are arranged within the trail. Set to true to have the current item’s breadcrumb show up first in the breadcrumb trail (this is revered of the normal behavior). It defaults to false if no value is passed in.
  • $force the fourth parameter, it is a boolean and controls whether or not generation of the breadcrumb trail should be forced (e.g. should the internal caching mechanism be bypassed). It defaults to false if no value is passed in.

Related Articles

Updated:

Breadcrumb Templates

Introduced in version 4.0.0, breadcrumb templates replace the anchor templates and the prefix and suffix settings. Most breadcrumb types have two breadcrumb templates. The first breadcrumb template is used when the breadcrumb is linked, the second is for when the breadcrumb is not linked (e.g. when it is the current item and “Link Current Item” is not set). An example for the Page post type:

  • “Page Template” contains the HTML Breadcrumb NavXT will used on breadcrumbs representing a post (instance) of the Page post type when they need to link to the Page they represent.
  • “Page Template (unlinked)” contains the HTML Breadcrumb NavXT will used on breadcrumbs representing a post (instance) of the Page post type that should not be linked (e.g. when it is the current item and “Link Current Item” is not set).

As of Breadcrumb NavXT 5.3.0, the default values for all instances of both breadcrumb templates are Schema.org BreadcrumbList compliant.

Breadcrumb templates accept the following HTML tags:

  • Anything allowed by wp_kses_allowed_html('post')
  • a and the following attributes: href, title, class, id, media, dir, relList, rel, lang, aria-hidden, data-icon, itemref, itemid, itemprop, itemscope, itemtype, xmlns:v, typeof, property, vocab, translate, and lang
  • img and the following attributes:alt, class, id, height, width, align, lang, src, srcset,aria-hidden, data-icon, itemref, itemid, itemprop, itemscope, itemtype, xmlns:v, typeof, property, vocab, and lang
  • span and the following attributes: title, class, id, dir, align, lang, xml:lang, aria-hidden, data-icon, itemref, itemid, itemprop, itemscope, itemtype, xmlns:v, typeof, property, vocab, translate, and lang
  • h1 and the following attributes: title, class, id, dir, align, lang, xml:lang, aria-hidden, data-icon, itemref, itemid, itemprop, itemscope, itemtype, xmlns:v, typeof, property, vocab, translate, and lang
  • h2 and the following attributes: title, class, id, dir, align, lang, xml:lang, aria-hidden, data-icon, itemref, itemid, itemprop, itemscope, itemtype, xmlns:v, typeof, property, vocab, translate, and lang
  • meta and the following attributes: content, property, vocab, and itemprop

Note that additional, HTML tags and attributes can be added via the bcn_allowed_html filter.

Breadcrumb templates also accept dynamic tags. These are replaced by Breadcrumb NavXT by the proper values when generating the breadcrumb trail. Breadcrumb templates accept the following dynamic tags:

  • %title% The title for the breadcrumb, typically the page title/name, tags are stripped and it is run through esc_attr().
  • %htitle% The title for the breadcrumb, typically the page title/name, tags are left intact.
  • %link% The URL to the resource (page) that the breadcrumb represents.
  • %type% The breadcrumb type. This is output as a comma delimited list, useful for setting as a group of classes for styling.
  • %ftitle% The title of the breadcrumb typically the page title/name, tags are stripped and it is run through esc_attr(). This version is never run through bcn_breadcrumb::title_trim(). This tag was introduced in version 4.3.0. This tag has been deprecated since 5.7.0.
  • %fhtitle% The title for the breadcrumb, typically the page title/name, tags are left intact. This version is never run through bcn_breadcrumb::title_trim(). This tag was introduced in version 4.3.0. This tag has been deprecated since 5.7.0.
  • bcn-aria-current This tag is replaced with aria-current="page" when the breadcrumb represents the current page. Otherwise, this tag is replaced by an empty string. This facilitates WAI-ARIA Breadcrumb support. This tag was introduced in version 6.3.0.

Note that additional, custom dynamic tags can be added via the bcn_template_tags filter.

Related Articles

Updated:

[bcn_display_attributes]

The [bcn_display_attributes] shortcode supports a subset of the parameters as the bcn_display_attributes() function. It may be entered into any post body.

[bcn_display_attributes linked=true reverse=false show_current_item=false use_taxonomy="all"]
  • linked the first available parameter, it is a boolean and controls whether or not the breadcrumbs in the breadcrumb trail are linked (if anchors are generated or not). Set to false to get a string without anchors. It defaults to true if no value is passed in.
  • reverse the second available parameter, it is a boolean and controls the order the breadcrumbs are arranged within the trail. Set to true to have the current item’s breadcrumb show up first in the breadcrumb trail (this is revered of the normal behavior). It defaults to false if no value is passed in.
  • show_current_item the third available parameter, it is a boolean and controls whether or not the current item is included in the breadcrumb trail. Set to true to have the current item’s breadcrumb show up in the breadcrumb trail (this is revered of the normal behavior). It defaults to false if no value is passed in.
  • use_taxonomy the fourth available parameter, it is a string and controls what taxonomies the attribute breadcrumb trails are generated for. Set to a specific taxonomy to restrict the breadcrumb trail generation to a single taxonomy. It defaults to all if no value is passed in.