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: