-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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