Show Main Blog Page Link in Divi Breadcrumbs Module

This post may contain referral links which may earn a commission for this site

My Divi Breadcrumbs Module allows you to display breadcrumbs links on your site. The breadcrumbs for a post or archive page by default include a link to the homepage. If you have configured a separate static "Posts Page" (in "Settings > Reading") and would like to include a link to it in your breadcrumbs too, you can do so using the following PHP:

add_filter('et_pb_dmb_breadcrumbs_crumbs', 'dbc_show_blog_page_link');

if (!function_exists('dbc_show_blog_page_link')) {
	function dbc_show_blog_page_link($crumbs) {
		if ((is_array($crumbs)) &&
			(is_single() || is_archive()) && 
			(get_option('show_on_front') === 'page')) { 	
			$blog_id = get_option('page_for_posts');
			array_splice($crumbs, 1, 0, array(
				array(
					'text'=>get_the_title($blog_id), 
					'url'=>get_permalink($blog_id)
				)
			));
		}
		return $crumbs;
	}
}

Hundreds of new features for Divi
in one easy-to-use plugin

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *