Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
You can use the following filter to modify the HTML code in your breadcrumbs so it is exactly as you want: https://rankmath.com/kb/filters-hooks-api-developer/#change-breadcrumb-args
Looking forward to helping you. Thank you.
Hello Alberto, thanks for the answer.
That code is clear to me, but I would need to target only to the last item of the breadcrumb, which is usually the current URL, to change the markup in that item only.
Hello,
To modify the last element you can do it as follows:
/**
* Filter to change breadcrumb html.
*
* @param html $html Breadcrumb html.
* @param array $crumbs Breadcrumb items
* @param class $class Breadcrumb class
* @return html $html.
*/
add_filter( 'rank_math/frontend/breadcrumb/html', function( $html, $crumbs, $class ) {
// theme_breadcrumb_function();
$customHTML = "YOUR HTML HERE";
$html[count($crumbs)-1] = $customHTML;
return $html;
}, 10, 3);
Looking forward to helping you. 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.