Hi there,
You have to know the structure of your current breadcrumbs array first using var_dump( $crumbs )
. Example,
function my_custom_breadcrumbs( $crumbs, $args ) {
var_dump( $crumbs );
return $crumbs;
}
add_filter( 'x_breadcrumbs_data', 'my_custom_breadcrumbs', 10, 2 );
Then load that page and copy the outputted array, it will be your reference. Let’s say, the $crumbs[0]
is home, then $crumbs[1]
is taxonomy, then there is $crumbs[2]
post type URL. That’s just a sample, but based on the outputted structure, let’s say you wish to add more, then you’ll have to create and add your own structure. Like this
function my_custom_breadcrumbs( $crumbs, $args ) {
if ( get_post_type () == 'post_type_A' ) {
//Override the existing $crumbs[2]
$crumbs[2]['label'] = get_the_title();
$crumbs[2]['url'] = get_permalink();
//Or add new
$crumbs[3]['label'] = 'Awesome Title';
$crumbs[3]['url'] = 'Awesome URL';
}
if ( get_post_type () == 'post_type_B' ) {
$crumbs[2]['label'] = 'A title from post type A';
$crumbs[2]['url'] = 'A URL from post type A';
$crumbs[3]['label'] = get_the_title();
$crumbs[3]['url'] = get_permalink();
}
return $crumbs;
}
add_filter( 'x_breadcrumbs_data', 'my_custom_breadcrumbs', 10, 2 );
It’s all about array, it depends if you’ll override the existing, or add new, there is no limitation. That’s just a sample as I don’t understand what you’re trying to achieve with post type A and B, they are different post types so there are no relationship. Only same post type could have parent and child relationship. I recommend contacting a developer.
Thanks!