Problem with Snippet “Remove a link from the Yoast SEO breadcrumbs”
-
Hello,
the snippet shown here works fine in most cases.
But it doesn’t work for parent pages (therefor are shown in the breadcrumb of the child page) with an “&” in the title. I tried it with
&
and& amp ;
(without spaces) as “$text_to_remove”.For WooCommerce shop categories it works with an
& amp ;
(without spaces) as “$text_to_remove”.How can I successfully exclude pages with “&” in the title from the breadcrumb?
Thank you in advance.PS: I also get the problem with the original code. But in my case I changed the code to still get the page title, but as simple text without link. Maybe it is of interest to add this to GitHub as well?
add_filter( 'wpseo_breadcrumb_single_link' ,'wpseo_remove_breadcrumb_link', 10 ,2); function wpseo_remove_breadcrumb_link( $link_output , $link ){ $text_to_remove = 'Products'; if( $link['text'] == $text_to_remove ) { $link_output = '<span class="breadcrumb_text">' . $link['text'] . '</span>'; } return $link_output; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Problem with Snippet “Remove a link from the Yoast SEO breadcrumbs”’ is closed to new replies.