Here’s the general principle of what you need to do:
- Hook into the
wpseo_breadcrumb_links
orwp_seo_get_bc_ancestors
API filters. - Add your Blog into the WordPress SEO Breadcrumb
$links
array, usingarray_splice
.
Place this in your theme’s functions.php
:
/**
* Conditionally Override Yoast SEO Breadcrumb Trail
* http://plugins.svn.wordpress.org/wordpress-seo/trunk/frontend/class-breadcrumbs.php
* -----------------------------------------------------------------------------------
*/
add_filter( 'wpseo_breadcrumb_links', 'wpse_100012_override_yoast_breadcrumb_trail' );
function wpse_100012_override_yoast_breadcrumb_trail( $links ) {
global $post;
if ( is_home() || is_singular( 'post' ) || is_archive() ) {
$breadcrumb[] = array(
'url' => get_permalink( get_option( 'page_for_posts' ) ),
'text' => 'Blog',
);
array_splice( $links, 1, -2, $breadcrumb );
}
return $links;
}
Note: You may need to update the code specific to your site or needs, but the general idea stays the same.