Archived topic
How to hide the Title part in the Breadcrumb (I'm using Yoast SEO)
9 replies · Started by Huy on July 2, 2018
Hi
I am using Yoast SEO and to show breadcrumb, I use this code
<?php if ( is_single() && ! is_single(3479) && ! is_single(4347) ) : ?>
<div class="page-header grid-container grid-parent">
<?php if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('<p id="breadcrumbs">','</p>');
} ?>
</div>
<?php endif; ?>
And this is the result: http://prntscr.com/k1il7t
However, I don't want to display the title of the post/page, I just want to show "Home >> Smoking". Is there any way to do it without using CSS to hide it away. In another way, I want that title will not be generated.
Thank you so much
Hi there,
you can use this filter for that:
add_filter( 'wpseo_breadcrumb_links', 'db_wpseo_breadcrumb_links' );
function db_wpseo_breadcrumb_links( $links ) {
if( sizeof($links) > 1 ){
array_pop($links);
}
return $links;
}
Hi David
Thank you for your help
I added that PHP code then this is the result: http://prntscr.com/k2038z
However, I want the category (smoking) is a link, not just a text. There's any way for me to do it?
Thank you so much
OK, try this:
function remove_breadcrumb_title( $link_output) {
if(strpos( $link_output, 'breadcrumb_last' ) !== false ) {
$link_output = '';
}
return $link_output;
}
add_filter('wpseo_breadcrumb_single_link', 'remove_breadcrumb_title' );
Thank you, David
It works for me!
Regards
You're welcome
Hello David,
how can I hide breadcrumb's title (Yoast) on mobile devices ONLY (screen-size <769px)? The breadcrumb's are to long on the mobile devices.
The function is realized exactly at Yoast-Blog:
On mobile:
Home >> Category1 >> Category2 >>
<h1>Long-tail titel</h1>
On Desktop:
Home >> Category1 >> Category2 >> Long-tail titel
<h1>Long-tail titel</h1>
Thank you very much
Slawek
Hi there,
could you start a new topic where you can provide a link to your site so i can take a look.
Where does that code go? I used the Yoast shortcode to add the breadcrumbs, now trying to remove the post title from the breadcrumbs.
Those are filters so one of these methods:
https://docs.generatepress.com/article/adding-php/
