Blog Page Crumb in Rank Math Breadcrumbs
Inserts the page set as your posts page after "Home" in Rank Math breadcrumbs on single posts, categories and tags.
Opens WPIDE on
Code
add_filter( 'rank_math/frontend/breadcrumb/items', function ( $crumbs ) {
$blog_id = (int) get_option( 'page_for_posts' );
if ( ! $blog_id || ! is_array( $crumbs ) || ! ( is_singular( 'post' ) || is_category() || is_tag() ) ) {
return $crumbs;
}
$blog_url = get_permalink( $blog_id );
foreach ( $crumbs as $crumb ) {
if ( isset( $crumb[1] ) && $crumb[1] === $blog_url ) {
return $crumbs;
}
}
array_splice( $crumbs, 1, 0, array( array( get_the_title( $blog_id ), $blog_url, 'hide_in_schema' => false ) ) );
return $crumbs;
} );
Notes
Does nothing when Settings > Reading has no posts page.
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.