For reference, this is how i do it in Yoast:
add_filter( 'wpseo_breadcrumb_single_link' ,'wpseo_remove_breadcrumb_link', 10 ,2);
function wpseo_remove_breadcrumb_link( $link_output , $link ){
$text_to_remove = 'Category Name';
if( $link['text'] == $text_to_remove ) {
$link_output = '<a href="PAGE URL">TEXT</a>';
}
return $link_output;
}
Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
Meanwhile we usually can’t provide custom code to our users due to we are a small team, now I was able to migrate that code to work on Rank Math, could you check it?
/**
*
* @param array $crumbs The crumbs array.
* @param Breadcrumbs $this Current breadcrumb object.
*/
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$ret = $crumbs;
$count = 0;
$modifiedCrumb = NULL;
$text_to_remove = 'Category Name';
foreach($crumbs as $crumb) {
if($crumb["0"]==$text_to_remove){
$modifiedCrumb = array(
"0"=>esc_html('PAGE NAME'),
"1"=>esc_url('/PAGE URL'),
"hide_in_scheme"=>false
);
break;
}
$count++;
}
if($modifiedCrumb!=NULL){
$ret[$count] = $modifiedCrumb;
}
return $ret;
}, 10, 2);
Looking forward to helping you. Thank you.
​​​​​​​
Thanks Alberto, it works perfect!
-
This reply was modified 4 years, 2 months ago by Ignacio.
Hello Ignacio,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.