Since Breadcrumb NavXT 3.5.0, two WordPress actions have been added into Breadcrumb NavXT. They are the bcn_before_fill
and bcn_after_fill
actions. As their names suggest, the first runs at the beginning of bcn_breadcrumb_trail::fill()
, and the second runs at the end of the same function. Both actions pass a reference to the current bcn_breadcrumb_trail
instance into the hooked function. This post quickly covers a use case for the bcn_after_fill
action.
Say for some reason, you want to exclude the home breadcrumb from the breadcrumb trail on only certain pages. Before you had to use object oriented programming techniques to do this. Now you only need 8 lines of code (including spaced braces for clarity). Simply place the code below in your functions.php, and change ‘page_foo’ to what ever page name/id you do not want to see the home breadcrumb on.
add_action('bcn_after_fill', 'foo_pop'); function foo_pop($trail) { if(is_page('page_foo')) { array_pop($trail->breadcrumbs); } }
Note that this will remove the last breadcrumb to be placed on the trail, which means you could end up removing a different breadcrumb depending on your site’s configuration (static front page vs just a blog, vs a multisite setup). In Breadcrumb NavXT 3.8.0 many of the trail members will be named, allowing easier access for removing the correct breadcrumb.
-John Havlik
[end of transmission, stay tuned]
I like the idea of giving them a name to do such stuff.
I tried this and it just breaks the whole website….?
Any ideas?
Thanks
fizzbacker
Could you be a little more specific? Where are you placing the code? What version of Breadcrumb NavXT? What do you mean by “it just breaks the whole website”?
-John Havlik
Hi!
I have now:
HOME > PAGE1 > PAGE2 > PAGE TITLE
I need to make:
PAGE1 > PAGE2
Delete a HOME (first word) and a page title.
It’s possible?
What’s the point of a breadcrumb trail if you remove both the base and the current item?
-John Havlik
What can I do to delete “HOME”?
There should be a check box for displaying the “blog” or the “home” breadcrumb, make sure they are not checked, simple as that.
-John Havlik
I think what “Boken” is trying to ask is how to you remove the word “Home” from the home or index page?
Roberta,
To do that, just change the
is_page('page_name')
tois_front_page()
. Or do things the correct way for that type of a page and check that WordPress conditional in an if statement surrounding yourbcn_display
orbcn_display_list
function call.-John Havlik
Thank you for this plug-in, very helpful.
I simply do not want the current page title to show in the breadcrumb (it is a bit redundant, I have the page title right below it). I see the code above that removes it from a specific page or post. What is the code to remove the post title from all my posts and pages.
thanks for your help!
Jeff,
This question is covered in the Breadcrumb NavXT FAQ (the official response to all requests relating to items already in the FAQ).
-John Havlik
how to remove the showing of like this Home / Solutions
Hi Manjunath,
Can you be more specific as to what you are trying to do?
-John Havlik
Hi John,
Let’s say i would like to add an item in breadcrump path when i’m on a specific category. is it possible to do that with your plugin ?
for instance if i’m in category 1 i would like to have :
Home > cutom item > category 1
Thanks
Odo
You can do that with a little code. You’ll want to use the
bcn_after_fill
action, just like in this article, but instead of removing an item, you’ll want to inject one. A while back I wrote an article on doing this. Please see the article Add a Static Breadcrumb to the Breadcrumb Trail.-John Havlik
Can anyone help me to show home page title instead of site name
like currently it is showing like sitename > page1 > ….
but i am i need title of my home page which is setup as frontpage
home > page1 >…
it is because i am using qtranslate plugin to create multilanguage pages
so i cannot add static Home text in the configuration of Breadcrumb NavXT
There currently isn’t a great way of dealing with this. Normally, I’d say change from %title% to “Home” or whatever you want to call it. However, that’s not necessarily workable. I know with other translation plugins (WPML and polyglot), there is a string translation table. There are extension plugins for Breadcrumb NavXT to deal with translation of the setting strings (breadcrumb templates in particular). I assume something similar could be written for qTranslate (though it looks like qTranslate has been abandoned, the fork qTranslate X seems to be the successor).
-John Havlik