-
Hi,
I wanted to change my breadcrumb category link to the separate WordPress page that has the same URL except the word Category in it.
(My current breadcrumb URL looks something like website.com/category/abc, and I want it to like to a separate pillar page website.com/abc)
I am using the following code from one of your previous threads:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
//Adding to single posts
global $post;
if(is_singular('post')){
//pass an array containing the name of the crumb, URL and
//hide_in_schema option
$catname = $crumbs[1][0];
$subcatname = $crumbs[2][0];
$value[] = array(
$catname,
'https://website.com/'.$catname,
'hide_in_schema' => false
);
$newValue[] = array(
$subcatname,
'https://website.com/'.$catname.'/'.$subcatname,
'hide_in_schema' => false
);
//add this value as the second item in array
array_splice( $crumbs, 1, 1, $value );
array_splice( $crumbs, 2, 1, $newValue );
return $crumbs;
}
return $crumbs;
}, 10, 2);The code is working well but the separator in the URL slug is missing (for example, URL slug appear as example page instead of example-page)
Can you please modify the above code to include a separator (dash symbol) in the URL slug?
The ticket ‘Breadcrumb Navigation Link’ is closed to new replies.