Rank Math Breadcrumbs at the Top of Posts and Pages
Prints the Rank Math breadcrumb trail at the top of single posts and pages, for themes with no built-in breadcrumb area.
Opens WPIDE on
Code
// Post types that get the breadcrumbs.
$wpide_rm_crumb_types = array( 'post', 'page' );
add_filter( 'the_content', function ( $content ) use ( $wpide_rm_crumb_types ) {
if ( ! function_exists( 'rank_math_get_breadcrumbs' ) || is_front_page() || ! is_singular( $wpide_rm_crumb_types ) || ! in_the_loop() || ! is_main_query() ) {
return $content;
}
return rank_math_get_breadcrumbs() . $content;
}, 5 );
Notes
Enable breadcrumbs under Rank Math > General Settings > Breadcrumbs first.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.