-
-
Save amboutwe/4b7a2f01366399281a53c355c5b78801 to your computer and use it in GitHub Desktop.
Your code does almost what I want. Your code removes the link completely. I just want it to remove the href. I still like having the path. I just don't want that parent item click able. Thanks!
add_filter( 'wpseo_breadcrumb_single_link' ,'wpseo_remove_breadcrumb_link', 10 ,2);
function wpseo_remove_breadcrumb_link( $link_output , $link ){
$text_to_remove = [ 'About', 'Training'];
if ( in_array( $link['text'], $text_to_remove, true ) ) {return;}
return $link_output;
}
I was able to figure my question out based on the previous responses. Thanks for sharing the initial post. Was very helpful.
add_filter( 'wpseo_breadcrumb_single_link' ,'wpseo_remove_breadcrumb_link', 10 ,2);
function removeBreadcrumbLink($link_output , $link) {
$link_output = str_replace('href="'.$link['url'].'"' , "" , $link_output);
return str_replace('data-wpel-link="internal"' , "" , $link_output);
}
function wpseo_remove_breadcrumb_link( $link_output , $link ) {
if(strpos( $link_output, 'breadcrumb_last' ) !== false ) {$link_output = '';}
$breadcrumbsLinkToBeRemoved = ['About', 'Scouting', 'Training', 'Resources', 'Giving'];
if(in_array($link['text'] , $breadcrumbsLinkToBeRemoved )) {
return removeBreadcrumbLink($link_output , $link );
}
return $link_output;
}
@korkoruz Both versions of your code remove the parent category completely, but I thought it should leave the category in the breadcrumb but just remove the href. Did I misunderstand, or is there a bug with your code?
Hello,
Please can someone help me.
My goal is to have the category/archive URL show in my breadcrumb path for posts tagged in specific archives only.
So a rule to say if the post is tagged 'news' include the /news/ breadcrumb.
I don't want to include the category breadcrumb rule sitewide as some posts have multiple categories.
But for my /blog/ section and /news/ section, I would like the posts breadcrumb path to parent said archive page.
This is not the proper place to request support. Please check out our extensive help section or visit the free support forum. If you require further support, upgrading to our premium version provides you with access to our support team.
Hi,
I am using the following code ,to remove "Shop" from breadcrumb in Schema.org but does not work. Any suggestions? Thank you beforehand.
add_filter( 'wpseo_breadcrumb_single_link' ,'wpseo_remove_breadcrumb_link', 10 ,2);
function wpseo_remove_breadcrumb_link( $link_output , $link ){
$text_to_remove = 'Shop';
if( $link['text'] == $text_to_remove ) {
$link_output = '';
}
return $link_output;
}
@foteinitaramonli These snippets are examples of how you can modify the Yoast SEO breadcrumb visual output (image below). These snippets will not alter the breadcrumb schema output nor will they alter WooCommerce's breadcrumb visual output.
Please consult the Yoast SEO schema documentation to change the breadcrumb schema. Please consult the WooCommerce breadcrumb documentation to change WooCommerce's breadcrumb output.
Hello,
thank you very much for these snippets.
But "$text_to_remove" does not work for text with an "&" in it.
I tried it with (all without blanks, of course):
- &
- & amp ;
- & #x26 ;
- & #38 ;
I don't want to show Home on homepage how to disable that ?
@Saad876 This is not the proper place to request support. Please check out our extensive help section or visit the free support forum. If you require further support, upgrading to our premium version provides you with access to our support team.
I am wondering if there is a way to disable the parent link from the child page.
Home >> About >> Our Council
Technically 'About' is not a Page, its the parent menu item that leads to 'Our Council'
Right now I'm using jquery to remove the link. It's nice because my breadcrumbs are intact but I don't like that I see it flash for a second with the link before the jquery removes the href.
$( "#breadcrumbs a:contains('About')" ).removeAttr( "href" );
I've thought about using something like this
$content = preg_replace("/(.*?)</a>/","",$content);
but would need to really understand the plugin code to make something like this work.