How to Remove or Unlink Specific Breadcrumb Links in Breadcrumb NavXT
Content
Many WordPress users rely on the Breadcrumb NavXT plugin to create a clear navigation path for their visitors. A common request is to modify the trail by removing the hyperlink from a specific breadcrumb, often a parent page that serves as a menu title but has no content of its own. This guide will walk you through the most effective methods to unlink individual breadcrumbs.
Why Unlink a Specific Breadcrumb?
You might want to unlink a breadcrumb for several reasons. The most frequent scenario involves a parent page that exists only to organize its child pages in the WordPress backend. Clicking on this breadcrumb link leads to an empty or irrelevant page, creating a poor user experience. The goal is to keep the breadcrumb's label in the trail for context but remove its functionality as a link.
Method 1: Using the bcn_breadcrumb_linked Filter (Recommended)
The most straightforward method is to use the bcn_breadcrumb_linked filter. This filter allows you to conditionally unlink any breadcrumb in the trail based on its properties, such as its URL or title.
Add the following code to your theme's functions.php file. This example unlinks any breadcrumb with the title "Psychotherapy":
function my_bcn_breadcrumb_linked_filter($linked, $type, $id) {
// Get the breadcrumb title
$breadcrumb_title = get_the_title($id);
// Check if the title matches the one you want to unlink
if ($breadcrumb_title == 'Psychotherapy') {
$linked = false; // Unlink this breadcrumb
}
return $linked;
}
add_filter('bcn_breadcrumb_linked', 'my_bcn_breadcrumb_linked_filter', 10, 3);
How it works: This function runs for every breadcrumb. It checks if the breadcrumb's title matches the one you specify. If it does, it returns false, which instructs Breadcrumb NavXT to output the breadcrumb as plain text without a link.
You can modify the condition to target a breadcrumb by its URL or any other available data passed to the filter.
Method 2: Using the bcn_after_fill Action
For more advanced control, you can use the bcn_after_fill action. This hook gives you direct access to the entire array of breadcrumb objects after the trail has been built.
The following code finds a breadcrumb by a specific URL and sets its URL to an empty string, effectively unlinking it:
function my_bcn_after_fill_action($trail) {
// Loop through each breadcrumb in the trail
foreach($trail->breadcrumbs as &$breadcrumb) {
// Check if this breadcrumb's URL is the one you want to unlink
if($breadcrumb->get_url() == 'https://yourdomain.com/your-page/') {
// Set the URL to an empty string to remove the link
$breadcrumb->set_url('');
}
}
}
add_action('bcn_after_fill', 'my_bcn_after_fill_action');
This method is powerful but requires a more precise targeting mechanism, such as the exact URL.
Important Considerations
- Theme Conflicts: If your theme has built-in Breadcrumb NavXT support, it may be outputting the trail automatically. Check your theme's options or consult its documentation to see if there is a setting to control this.
- Child Theme: Always add custom code to a child theme's
functions.phpfile to prevent your changes from being lost during theme updates. - Testing: After adding any code, clear your site's cache (if you use a caching plugin) and test thoroughly to ensure it works as expected.
By using these filters, you can precisely control the output of your breadcrumb trail and ensure a seamless navigation experience for your users.
Related Support Threads Support
-
Remove on link from the breadcrumb trailhttps://wordpress.org/support/topic/remove-on-link-from-the-breadcrumb-trail/
-
Remove linkhttps://wordpress.org/support/topic/remove-link-15/
-
Remove RDFahttps://wordpress.org/support/topic/remove-rdfa/
-
Breadcumbs NavXT remove the breadcumbs above the posthttps://wordpress.org/support/topic/breadcumbs-navxt/
-
[Plugin: Breadcrumb NavXT] Remove parents links of breadcrumbhttps://wordpress.org/support/topic/plugin-breadcrumb-navxt-remove-parents-links-of-breadcrumb/
-
removing part of the hierarchyhttps://wordpress.org/support/topic/removing-part-of-the-hierarchy/
-
How to Unregister Breadcrumb NavXT Widgethttps://wordpress.org/support/topic/how-to-unregister-breadcrumb-navxt-widget/
-
Remove "sie sind hier"https://wordpress.org/support/topic/remove-sie-sind-hier/
-
How can I control the block of Breadcrumb Trail?https://wordpress.org/support/topic/how-can-i-control-the-block-of-breadcrumb-trail/
-
Removing Breadcrumb NavXT – doesn’t workhttps://wordpress.org/support/topic/removing-breadcrumb-navxt-doesnt-work/
-
How to exclude custom taxonomyhttps://wordpress.org/support/topic/how-to-exclude-custom-taxonomy/
-
Remove current item from breadcrumb?https://wordpress.org/support/topic/remove-current-item-from-breadcrumb/
-
Truncating the current “crumb”https://wordpress.org/support/topic/truncating-the-current-crumb/
-
how to unlink breadcrumbhttps://wordpress.org/support/topic/how-to-unlink-breadcrumb/
-
How to Turn off Schema of Breadcrumb NavXT?https://wordpress.org/support/topic/how-to-turn-off-schema-of-breadcrumb-navxt/
-
Unlink breadcrumb path termshttps://wordpress.org/support/topic/unlink-breadcrumb-path-terms/
-
make menu parent not selectablehttps://wordpress.org/support/topic/make-menu-parent-not-selectable/
-
Remove Breadcrumb on 404 pagehttps://wordpress.org/support/topic/remove-breadcrumb-on-404-page/
-
Remove 'Protected:' in breadcrumbhttps://wordpress.org/support/topic/remove-protected-in-breadcrumb/
-
How to remove ‘sites’ from Multisite breadcrumb?https://wordpress.org/support/topic/how-to-remove-sites-from-multisite-breadcrumb/
-
Breadcrumb disaabling top menu navigationhttps://wordpress.org/support/topic/breadcrumb-disaabling-top-menu-navigation/
-
Remove "a" tag from first object on trailhttps://wordpress.org/support/topic/remove-tag-from-first-object-on-trail/
-
Unlink or remove specific pageshttps://wordpress.org/support/topic/unlink-or-remove-specific-pages/
-
Remove specific category (uncategorized) or page from breadcrumbshttps://wordpress.org/support/topic/remove-specific-category-uncategorized-or-page-from-breadcrumbs/
-
Remove Parent Categoryhttps://wordpress.org/support/topic/remove-parent-category-2/
-
best way to remove from search resultshttps://wordpress.org/support/topic/best-way-to-remove-from-search-results/
-
Remove "You are here"https://wordpress.org/support/topic/remove-you-are-here/
-
Remove Link From BreadCrumb on certain parent pageshttps://wordpress.org/support/topic/remove-link-from-breadcrumb-on-certain-parent-pages/
-
Remove links buddypress extensionhttps://wordpress.org/support/topic/remove-links-buddypress-extension/
-
remove breadcrumb for all forumhttps://wordpress.org/support/topic/remove-breadcrumb-for-all-forum/
-
remove link in the breadcrumbshttps://wordpress.org/support/topic/remove-link-in-the-breadcrumbs/
-
Bread Crumb Navxt 5.1https://wordpress.org/support/topic/bread-crumb-navxt-51/