sorry, this is the filter that you told us to put –
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);
Hello,
Thank you for contacting Rank Math for help with your breadcrumbs and URL structure.
The rank_math/frontend/breadcrumb/items filter you provided should work to change the breadcrumbs on your website. It’s not clear what you are trying to achieve. At the beginning you say you do not want to change the URLs but all the examples you gave are URL changes.
If you want to change the text of a breadcrumb item, You can set $crumbs[1][0] to your desired text for example:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
$crumbs[1][0] = 'booook';
return $crumbs;
}, 10, 2);
The example above would need to be modified with a conditional statement to match the current breadcrumb text.
If I misunderstood please can you provide more details. You can use imgbb.com to share screenshots and loom.com to share a screencast. Any additional details you can provided will be appreciated.
Looking forward to helping you.
Hi,
I need to change the Url of the second bead crumb (category page) to URLs that exist on the website
for example –
this is a category page – category page
and we want that this page will be the one that the user gets when clicking on the second bread crumb
bread knives main page
and this type of pages:
Current category page – https://knivesacademy.com/chef-knives/
we want change to the main page of chef knives
https://knivesacademy.com/chef-knives-guide/
future pages examples –
the category page now is category page
and we ant that that main page of the blog will be https://knivesacademy.com/blogs/
when a user clicking on the second bred crumb, her it aikk be “Blog” the user will get to https://knivesacademy.com/blogs/
and
https://knivesacademy.com/recipe/
Would like to change to –
https://knivesacademy.com/recipes/
I hope you understand that the second bred crumb will be the main page of the subject (buying-guides for example) and not the category page
Hello,
Since there are multiple categories for which you want to change the URLs, you will have to modify the filter to check the current URL of the 2nd breadcrumb and then update it accordingly. This type of customization falls out of the scope of our support and you will have to do it yourself or hire a developer to do this for you.
Please don’t hesitate to get in touch in case you need any other assistance.
Thanks.
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.