Hello,
Thank you for contacting the support.
You can modify and use this filter to modify the link of the second element of the breadcrumbs:
/**
* Allow changing or removing the Breadcrumb items
*
* @param array $crumbs The crumbs array.
* @param Breadcrumbs $this Current breadcrumb object.
*/
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$crumbs[1][1] = 'https://www.google.com/'; // Add the desired URL
return $crumbs;
}, 10, 2);
You can replace https://www.google.com/
in the above code with the desired URL.
Here’s a guide that you can follow to add the filter to the website:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope this helps.
Thank you.
Thank you for that.
I would like to do it to all of my categories, not only one.
Is it possible?
Hello,
Please share a few current URLs and the new URLs so that we can see if there’s a pattern.
Looking forward to hearing back from you.
Thank you.
Hello,
You will need to modify the filter I shared previously and add conditions to it as the future URLs are following a different pattern.
For the current URLs, you can modify and try using the below filter:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$url = explode('/', $crumbs[1][1]);
if(end($url) === ''){
array_pop($url);
}
$url[count($url)-1] .= '-guide';
$crumbs[1][1] = implode('/', $url);
return $crumbs;
}, 10, 2);
Hope this helps.
Thank you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.