Add a Static Breadcrumb to the Breadcrumb Trail

In some cases WordPress may be not be running your entire site. In these instances, there may be a root above what WordPress knows about. To add a breadcrumb to represent this, you have two options.

  1. Breadcrumb NavXT Menu Magic can be used. You will need to have a ‘custom item’ menu entry that represents this off WordPress resource and is the root to all of the other menu entries.
  2. Write a little code in a site specific plugin.

The Code

The Menu Magic method is neat and does not require any code writing. However, that’s not what this article is really about. Besides, the required code is quite simple. The following code just needs to be placed in a site specific plugin (or your theme’s functions.php if that floats your boat):

add_action('bcn_after_fill', 'my_static_breadcrumb_adder');
function my_static_breadcrumb_adder($breadcrumb_trail)
{
	$breadcrumb_trail->add(new bcn_breadcrumb('STATIC_TITLE', NULL, array('home'), 'STATIC_URL'));
}

After placing this code into your site specific plugin, you will need to update two portions of it. Replace STATIC_TITLE with the title of the resource this breadcrumb represents, and replace STATIC_URL with the URL to the resource represented by this breadcrumb. That’s it. Simple, right?

-John Havlik

[end of transmission, stay tuned]

6 thoughts on “Add a Static Breadcrumb to the Breadcrumb Trail

    • While your host may already support PHP5.6, if Breadcrumb NavXT is warning that you are using an out of date PHP version, then it is likely your site is configured to use an older version of PHP. The version Breadcrumb NavXT lists in the warning message is the PHP version that your WordPress install is using. Please check your .htaccess file to see if it is specifying a specific PHP version.

      -John Havlik

  1. Hello,
    Where can I found what are the “args” the new bcn_breadcrumb() object accepts?
    My goal is to display a totally custom breadcrumb on a page witch doesn’t have one.

    Thanks for your help and your plugin.

  2. Hi,

    I added the code accordingly but how can I set the new part to the end? I was not able to find a solution for it yet :(

    best,
    Michael

Leave a Reply

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