Hi Yannick,
I’m glad everything went well!
I added your request to my list. Currently, it is only possible via filters. Here’s one that I just created for this occasion:
/**
* Filters out TSF's last breadcrumb if at least 2 items are in the breadcrumb.
* Only does this after wp_head to prevent affecting the structured data.
* A better hook would've been <code>wp_body_open</code>, but not all themes have this yet.
*/
add_action(
'wp_head',
function() {
add_filter(
'the_seo_framework_breadcrumb_list',
fn( $list ) => count( $list ) > 1 ? array_slice( $list, 0, -1 ) : $list,
);
},
PHP_INT_MAX,
);
Here, you can learn where to put filters: https://tsf.fyi/d/filters/#where.
Hi Sybre,
thank you very much for your response and your example. Why are you not using the “the_seo_framework_breadcrumb_shortcode_output” filter? Thats what I played with before going with a CSS only solution. Perhaps it is helpful for someone else.
.tsf-breadcrumb .breadcrumb-item:not(:nth-child(-n + 2)):last-of-type {
display:none;
}
.tsf-breadcrumb .breadcrumb-item:not(:nth-child(-n + 1)):nth-last-of-type(2)::after {
display:none;
}
Hello Yannick!
It wasn’t apparent to me you wanted it removed from either the Schema.org output or the shortcode, so I created a filter that removed them both while mitigating the need for complicated CSS queries. But I’m glad you’ve found a workaround 🙂