Skip to content

Instantly share code, notes, and snippets.

@Dudo1985
Created June 29, 2021 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dudo1985/24cd203365b0dec043d4324216a2650b to your computer and use it in GitHub Desktop.
Save Dudo1985/24cd203365b0dec043d4324216a2650b to your computer and use it in GitHub Desktop.
This code will remove the text near the breadcrumb title generated by rankmath plugin
add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
//Title is the firs key of the last sub array
end($crumbs); // move the internal pointer to the end of the array
$last_key = key($crumbs); // fetches the key of the element pointed to by the internal pointer
//Here I don't use get_the_title because it run after filters are applied.
//This causes that stars near title will appear in schema title
$crumbs[$last_key][0] = get_post_field('post_title', get_the_ID(), 'raw');
// And return the breadcrumbs
return $crumbs;
}, 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment