I was able to achieve what I needed using a snippet, hopefully this functionality will be added to the UI in the future so it won’t rely on a dev to add.
I closed this ticket but the issue is not resolved so I reopened. I need to know how to just rename the breadcrumb for the custom post archive page like I could with Yoast. This is the snippet I used:
/**
* 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 ) {
if(is_singular('health_term')){
$modifiedCrumb = array(
"0" => esc_html('Men\'s Health A-Z'),
"1" => esc_url('/mens-health-a-z/'),
"hide_in_scheme" => false
);
$crumbs[count($crumbs)-2] = $modifiedCrumb;
}
// And return the breadcrumbs
return $crumbs;
}, 10, 2);
It works if there are no child posts for example
Home // Men’s Health A-Z // Blood Pressure
but on a child page, the old custom post type name appears as well as the renamed and does not include the correct hierarchy
This:
Home // Health Term // Men’s Health A-Z // Hypertension
should be:
Home // Men’s Health A-Z // Blood Pressure //Hypertension
Long story short I need to rename Health Term to Men’s Health A-Z in the breadcrumb
Hello,
Thank you for contacting Rank Math today.
To rename the second term in the breadcrumbs you need to access it with the following variable:
$crumbs[1][0] = 'Change the name here';
If you want to remove that from the breadcrumbs you might want to unset that crumb entirely with the following:
unset($crumbs[1]);
Hope this helps to get closer to the final solution for this issue.
Don’t hesitate to get in touch if you require any further assistance.
Thanks Miguel, I appreciate your help, it works as expected now.
Hello,
We are super happy that your issue is resolved. 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.