Breadcrumbs adding category and blog page home plus more

Hi, my aim was to add breadcrumbs to the top of posts/pages in Pro. I’m not using the header builder option.
I used the option at the bottom of Theme Options > Header where you can click breadcrumbs on. That worked, but…

Then I wanted the breadcrumbs to be Home > Blog Page Home > Category > Post rather than Home > Blog Page Home > Post

I semi-succeeded by following instructions on this page (adding a hunk of code to child theme functions):
https://theme.co/apex/forums/topic/show-category-in-breadcrumbs/#post-878067 … but, it now is Home > Category > Post with no Blog Page Home included

Additionally, the page link above says, “This content is old and no longer supported. You may use at your own risk, but no official support will be provided for anything listed here.”

  1. So, one question is if you have a preferred up-dated solution to this?
  2. I have a page set to home page and a page set to blog home page. Is there a way for the breadcrumbs to go Home > Blog Page Home > Category > Post? That would be fantastic.
  3. If that can be done, is there a way to increase the size of the home symbol?

So, to summarize, I turned the breadcrumbs on from the Theme Options header section.
I’m trying to have the bread crumbs follow Home > Blog Page Home > Category > Post. And, I’m trying to increase the size of the Home symbol.

Thank you!

Hi ShermanPotter,

To increase the size of the home symbol in breadcrumbs, please add this CSS code snippet in (Pro > Theme Options > CSS):

.x-breadcrumbs .x-icon-home {
    font-size: 1.5em;
}

To get this exact breadcrumbs structure (Home > Blog Page Home > Category > Post), please add this code snippet in the functions.php file of the child theme directory:

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

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

			$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;  
}

I hope this helps.
Thanks.

Hello, and thank you.

EDIT UPDATE: That worked!
If someone else is trying to do the above: I removed the old code (in my link) and replaced it with Alaa’s code.

Thank you Alaa!!!




Am I supposed to replace the existing breadcrumb code in my child functions?
By existing breadcrumb code, I mean the code from the link below.

Or do I keep that existing code and add the code that you posted beneath it?

thank you!

added: the css to increase the house symbol worked. thank you

Hey @ShermanPotter,

You will need to use the code provided by @Alaa because the previous code is outdated.

Thanks.

How do you do this to not display Blog Page Home? So it just goes Home > Category > Post?

Hi @Jessvb

Please try this one

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

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

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

Thanks!

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