How to Remove Url Prefix Yoast Breadcrumbs on WordPress

1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, avr: 4.67)

Yoast SEO WordPress plugin is one of the most popular and downloaded. It’s a powerful plugin that comes with many great features including On-Page rankings, auto-generated sitemaps and breadcrumbs.

Breadcrumbs on Yoast are important to assists the user in creating al “mental map” of how the website is laid out, along with giving them links to page hierarchy. This tutorial demonstrates step by step how to remove Url prefix Yoast Breadcrumbs on WordPress.

Prerequisites

Before starting with this guide, make sure you have privileges to access the WordPress root directory project and assumes that you have implemented coding into your theme. If you don’t have to do yet, put the following code where you want the breadcrumbs to be

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

1: Remove Post Title on Yoast Breadcrumbs

To remove a link from Yoast breadcrumbs you need to filter the single link hook. For example, if your breadcrumbs are Home / CMS / WordPress / Post Title / and you want to remove the last Post Tietle you could do the following:

Go into your WordPress project’s root directory then add the following code into a file functions.php

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

Save these file was modified then refresh your browser


2: Remove Certain Category on Yoast Breadcrumbs

To remove a certain category name on Yoast Breadcrumbs. For example, if your breadcrumbs are Home / CMS / WordPress / Post Title / and you want to remove the WordPress you could do the following:

Go into your WordPress project’s root directory then add the following code into a file functions.php

function remove_certain_category($link_output, $link ){
 
    if( $link['text'] == 'Wordpress' ) {
        $link_output = '';
    }
    return $link_output;
}
add_filter('wpseo_breadcrumb_single_link' ,'remove_certain_category', 10 ,2);

Save these file was modified then refresh your browser


3: Remove Home on Yoast Breadcrumbs

Home URL for linking to the “Home” page first path on Yoast Breadcrumbs. If you want to remove that you could do the following

Go into your WordPress project’s root directory then add the following code into a file functions.php

function remove_home_breadcrumb($links) {
	if ( $links[0]['url'] == home_url('/') ) {
		array_shift($links);
	}
	return $links;
}

add_filter('wpseo_breadcrumb_links', 'remove_home_breadcrumb');

Save these file was modified then refresh your browser


If this tutorial could help you, please rate above Star button rating and share to help others find it! Feel free to leave a comment below

Recommended For You

Iman

About the Author: Iman

Working as Freelancer in Information Technology, Computer Programming in Node.JS ecosystem, like to share the knowledge to the people