Pro-Child: Breadcrumbs with category -> Where is breadcrumbs.php?

Hi Team,

I also need urgently a “correct” breadcrumb-trail with the category in the trail (I only use one category per post).
I found a solution from you for X, but it’s not working for pro isn’t it?

I use the breadcrumbs-element in Pro-Header and I will try it by myself. But which file to edit?
…/wp-content/themes/pro/framework/legacy/cranium/headers/views/ethos/_breadcrumbs.php

seams to be the wrong one.
Thank you

Hi,

The code provided is for X default breadcrumb, it doesn’t apply to the breadcrumb element.

The breadcrumb element code is part of the core and we don’t recommend changing it as it will cause more harm than good.

This is something we can add to our list of feature requests. This way it can be taken into consideration for future development. All of these items are discussed with our team internally and prioritized based on the amount of interest a particular feature might receive. Thanks!

Hi Paul,

as I wrote this was for X.
What does it mean “is part of the core”? I can’t use a child setup to modify the breadcrumbs?

“This is something we can add to our list of feature requests”
Yes. This is discussed earlier in several threads again and again. Unfortunately I should provide my client with a solution in the near future and not with a maybe :wink:

So there is no _breadcrumbs.php we can customize our own in a child setup?
and there is also no possibility to utilize functions.php?

Thank you.

Hi there,

The new breadcrumb structure uses filters, I may able to help if you can provide information of what you wish to achieve. I tried the breadcrumbs on my end and it’s correctly displaying the category and post breadcrumbs trail. Is it just changing the main parent of your single post?

Maybe you can add this code to your child theme’s functions.php

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

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

/* home root */

    $crumbs[0]['label'] = 'GET ME HOME';
    $crumbs[0]['url'] = 'http://example.com';

/* blog page */

    $crumbs[1]['label'] = 'BLOG INDEX';
    $crumbs[1]['url'] = 'http://example.com/blog/';


  }
  return $crumbs;
}

There are other filters too, like for breadcrumbs data.

Thanks!

Hi Rad,

thanks for chiming in!
I have different category (cat1, cat2, cat3) for my posts

What I expect to see as breadcrumps:
Home -> news -> cat1 -> title of the post

What I see:
Home -> News -> title of my post

“News” is my post page. And if all is really cool I do not see “News”.
The world-best-breadcrumbs-trail-ever would be:
Home -> Cat1 -> title of posting

I think I have to take a really close look at your code. It seams possible to do this!
Thank you,
Michael

Hi there,

Ah, then what you need is something like this

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 ) {
    $crumbs[1]['label'] = $category[0]->name;
    $crumbs[1]['url'] = get_category_link( $category[0]->term_id );
    
   unset($crumbs[2]); //to make sure category won't duplicate

    }
  }
  return $crumbs;
}

Hope this helps.

2 Likes

Thank you so much!
I have to do a little bit tweaking to perfectly fit my needs (now it fits 110%! :slight_smile: )
This is really a great solution. I believe this helps a lot of people here.

Have a great weekend and again: thank you for a great support.

2 Likes

You are most welcome. :slight_smile:

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