Hello,
Thank you for contacting the support, and sorry for any inconvenience that might have been caused due to that.
Do note that this filter code is just a placeholder to show you the basics of modifying the breadcrumbs.
You’ll need to edit this as per your requirements to successfully change the breadcrumbs title value.
Here’s a reference ticket where this filter is implemented: https://support.rankmath.com/ticket/%e2%98%85-how-to-assign-a-custom-field-to-breadcrumb-title/?view=all#post-66294
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Thank you for your prompt support – its a bit beyond me but Ill give it a bash.
Hello,
I am glad that we are able to address your concern. Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.
Hi I used this code and it made no difference
The only thing I changed was if(is_page(’18’)) and the actual title
is there something I am doing wrong? I want to replace the page title with a single word “Dentist” Or I can even use the focus keyword
Thanks
/**
* this is an example to remove the second item in your post 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 ) {
// Check if we are viewing single posts
if(is_page(’18’)){
// Apply here your custom login to generate the final
// element of the breadcrumb (the breadcrumb title)
$newBreadcrumbTitle = “Dentist”;
// The last element in the $crumbs array is the post’s
// breadcrumb title, so we have to update it:
$crumbs[count($crumbs)-1] = $newBreadcrumbTitle;
}
// And return the breadcrumbs
return $crumbs;
}, 10, 2);
sorry, I changed it to if(is_page(18)) and still not working
Hello,
Please try this approach instead:
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
global $wp_query;
if($wp_query->post->ID == '18'){
$newBreadcrumbTitle = "Dentist";
$crumbs[count($crumbs)-1] = $newBreadcrumbTitle;
}
return $crumbs;
}, 10, 2);
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
thank you, its still not working. It is correct that I am adding this to my functions.php?
Hello,
The code should be inserted in your theme’s functions.php file. Here is a guide with regards to inserting filter/hook to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/
I tested the code on my end and it seems to have detected the post by ID.
If the issue persists, on your end. we might need to take a closer look at the settings. Please edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
We really look forward to helping 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.