A topic that comes up time to time in support requests is how to unlink a breadcrumb. Typically this is due to having an empty page that exists to facilitate a logical hierarchy. Naturally, linking to this blank page in the breadcrumb trail is not useful. While it is bad form to have a breadcrumb in the breadcrumb trail that is not linked, there is a filter that can facilitate this behavior.
The presented solution is a simplistic example for a single page. However, it can be extended for multiple pages, or taxonomy terms. Finally, rather than being hard-coded, the IDs could come from a post_meta/term_meta field.
The Code (Breadcrumb NavXT 6.5)
Introduced in Breadcrumb NavXT 6.5, the bcn_breadcrumb_linked
filter makes changing the linked status quite simple:
add_filter('bcn_breadcrumb_linked', 'my_breadcrumb_url_stripper', 3, 10);
function my_breadcrumb_url_stripper($linked, $type, $id)
{
if(in_array('post-page', $type) && (int) $id === MYPAGEID)
{
return false;
}
return linked;
}
The Code (Pre-Breadcrumb NavXT 6.4)
Due to changes introduced in Breadcrumb NavXT 6.4, the below only works with versions of Breadcrumb NavXT prior to 6.4:
add_filter('bcn_breadcrumb_url', 'my_breadcrumb_url_stripper', 3, 10);
function my_breadcrumb_url_stripper($url, $type, $id)
{
if(in_array('post-page', $type) && (int) $id === MYPAGEID)
{
$url = NULL;
}
return $url;
}
After placing this code into your site specific plugin, you will need to update one part of it. Just replace MYPAGEID with the ID of the page you want to remove the link to. That’s it. Simple, right?
-John Havlik
[end of transmission, stay tuned]