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', NULL, true));
}

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]