Documentation

Notice: Information regarding the core classes is available in the source code (nearly every line of code has an accompanying comment line). Users interested in the inner workings of the core classes should check out the Github project for Breadcrumb NavXT Master.

Table of Contents

  1. Using Breadcrumb NavXT
    1. Using the Settings Page
    2. Using the Widget
    3. Using bcn_display() and bcn_display_trail()
  2. Hook Reference
    1. Action Reference
    2. Filter Reference
  3. Code Examples
    1. CSS Styling
    2. Direct Class Access

Using Breadcrumb NavXT

Using the Settings Page

Breadcrumb Templates

Introduced in version 4.0.0, breadcrumb templates replace the anchor templates and the prefix and suffix settings. These templates accept HTML, and 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.
  • %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.

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

Using bcn_display() and bcn_display_list()

bcn_display is the main display function for Breadcrumb NavXT. It will generate a breadcrumb trail for the current page (resource, not post type). The following is the function’s prototype

bcn_display($return = false, $linked = true, $reverse = 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.
  • $linked the second 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 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.

bcn_display_list() accepts the same parameters as bcn_display(). The difference is in how the breadcrumb trail is assembled. bcn_display() places a breadcrumb separator between breadcrumbs in the trail. bcn_display_list() wraps each breadcrumb with <li> tags.

Using the Widget

Since version 3.0.0, Breadcrumb NavXT has shipped with a built in WordPress sidebar widget. In Breadcrumb NavXT version 3.5.0 the included widget was rewritten and is multi instance capable. The widget allows you to place a breadcrumb trail in your theme without touching any of your theme’s files. Since Breadcrumb NavXT has a two different display functions (bcn_display() and bcn_display_list()), along with three input variables for these functions ($return, $linked, $reverse), the widget has a few settings available to the user.

Currently, the following settings are available:

  • A field to enter a title for the output widget, this works just like the title on any other widget.
  • Whether to output the trail as a list or not. If checked, the output trail will be placed in an unordered list, with each breadcrumb belonging to its own list element.
  • Whether to link the breadcrumbs or not. If checked (default), each of the breadcrumbs in the breadcrumb trail will have a hyperlink.
  • Whether to reverse the order of the trail or not. If checked, the breadcrumb trail will be output in reverse order (the leftmost breadcrumb (or first breadcrumb in a list output) will be the breadcrumb for current page).
  • Whether to hide the trail on the front page or not. If checked, the breadcrumb trail for the front page of your site will not be displayed (e.g. when is_front_page() evaluates to true).

The widget still uses the settings values specified in the Breadcrumb NavXT settings page to define its behavior while filling the breadcrumb trail.

on

423 thoughts on “Documentation

  1. Hi John,

    Thanks for this good plugin. Now I have one below query.

    On my news details page currently news slug is displaying into url. Now I want to display this slug into breadcrumb by using this plugin. I have used some bcn_display function but it is not displaying.

    Can you please help me and let me know which func/code I can apply on news details template so news slug will display into breadcrumb.

    I am waiting for your reply.

    Thanks,
    Sunil

  2. Hi there,

    I’m using your plugin within our companies intranet and there are some problems with categories und sub-categories.

    cat_A
    sub-cat_A1
    sub-cat_A2
    sub-sub-cat_A2_1
    sub-sub-cat_A2_2
    sub_cat_A3
    sub-sub-cat_A3_1
    sub-sub-cat_A3_2
    sub_cat_A4

    The breadcrumbs for an article in sub-sub-cat_A3_2 are displaying correctely BUT the breadcrumbs for an article of sub-sub-cat_A2_1 not (same category structure). In this case there is only sub-cat_A2 displaying, the rest is missing after opening the article…

    Can somebody help me?

    • Hi Nick,

      Is the post an explicit member of more than just the “sub-sub-cat_A2_1” category (e.g. an explicit member of “sub-cat_A2” and an explicit member of “sub-sub-cat_A2_1”)? If that is the case, I recommend changing the post to be only an explicit member of “sub-sub-cat_A2_1” (it will be an implicit member of the parent categories of “sub-sub-cat_A2_1”). You may also try the master branch of Breadcrumb NavXT on GitHub, its term selection behavior has changed slightly that may fix this for you.

      -John Havlik

      • Yes, the article was a member of more than just the sub-sub-category. I changed it so the article is explicit member of tha last category in the row and it works great! Good to know (explicit vs. implicit)

        THX A LOT! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *