Add Yoast breadcrumbs without last breadcrumb open

Add Yoast breadcrumbs without last breadcrumb

To begin with, add the breadcrumbs themselves. Go to the Yoast plugin settings and activate this option in “Display in search results” tab.

After that, go to the single.php yours theme file, and add this code to it:

if (function_exists('yoast_breadcrumb')) {
	yoast_breadcrumb('<p id="breadcrumbs">', '</p>');
}

Breadcrumbs will begin to appear on the site, but the last crumb that leads to the article itself will also be displayed. To remove it, add the following code to your theme function.php file.

function delete_last_breadcrumb( $link_output) {
    if(strpos( $link_output, 'breadcrumb_last' ) !== false ) {
       $link_output = '';
    }
    return $link_output;
    }
	
    add_filter('wpseo_breadcrumb_single_link', 'delete_last_breadcrumb' ); 

After use filter change output function for validate html

if (function_exists('yoast_breadcrumb')) {
    yoast_breadcrumb('<p id="breadcrumbs">', '</span></span></p>');
}
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation