Breadcrumbs with custom blog page

Hi,

Is it possible to have a custom blog page show in the breadcrumbs ? My situation is that I have not defined a blog page within the WordPress settings, as I am using The Grid to define this with a shortcode on a custom page.

Based on this, I now have Home > Blog > Category > Post. What I am looking to do is to replace any instances of “blog” with “Articles”, so Home > Articles > Category > Post etc…

I am already using the below function, so I guess it needs some small modification

add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);

	function post_parent_trail ($crumbs, $args) {
		if ( array( 'post', 'product' ) ) {

			$category = get_the_category( get_the_ID() );

				if ( count( $category ) > 0 ) {

					$cat_array = array();
					$cat_array[1]['label'] = $category[0]->name;
					$cat_array[1]['url'] = get_category_link( $category[0]->term_id );

					array_splice($crumbs, 2, 0, $cat_array);
				}
		}
	return $crumbs;  
}

Thanks

Hi @phenomlab,

Thanks for reaching out.

You mean just change the blog index page in the breadcrumb, right? Then please change that code to this

add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);

	function post_parent_trail ($crumbs, $args) {
		if ( is_singular('post') ) {

			$post_ID  = 3433;					
			$post_array = array();
			$post_array[1]['label'] = get_the_title( $post_ID );
			$post_array[1]['url'] = get_permalink( $post_ID );
			array_splice($crumbs, 2, 0, $post_array);
		}
	return $crumbs;  
}

All you need to change is the post ID 3433, and it should be the ID of the page you created where your grid is.

Thanks!

Thanks @rad. However, I now see “Blog > Articles >…” whereas I’d just like to see “Articles >…”
Is there a way to remove the “blog” part as all this does it redirect to the homepage.

In addition, I’m using the X_Breadcrumbs shortcode on a custom post page I’m using, but this is the V1 version. Is there a shortcode for the V2 version as this looks much better.

Hi There,

Please update the previous code to this:

add_filter('x_breadcrumbs_data', 'post_parent_trail', 9999999, 2);

function post_parent_trail ($crumbs, $args) {
	if ( is_singular('post') ) {

		$post_ID  = 3433;					
		$post_array = array();
		$post_array[1]['label'] = get_the_title( $post_ID );
		$post_array[1]['url'] = get_permalink( $post_ID );
		array_splice($crumbs, 2, 0, $post_array);

		unset($crumbs[1]);
	}
	return $crumbs;  
}

The version 2 of breadcrumbs element is not available yet.

Stay tuned :slight_smile:

Works perfectly. Thanks

Thanks. Will look forward to it’s release (if I understood that correctly)

@thai
Wait - quick thought as I’ve just re-read your reply.

If you look at my site here https://inocul8r.net/articles, you’ll see the breadcrumb style I’m using (from the Element builder), and then the breadcrumb style in any of the posts, for example https://inocul8r.net/articles/why-you-should-never-neglect-physical-security/

You’ll notice that the first is the newer layout style (that I want to use), whilst the other is the older breadcrumb style.

Regretfully, you could not apply the Breadcrumbs element’s style to the breadcrumbs bar. That would need additional customization which would veering into custom development which is outside the scope of our support.

Thank you for understanding.

@christian_y Understood. Thanks

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.