Hello guys,
Did some research and got some elements to answer my question but I think it can be useful to other users if we can come up with a more straightforward way to alter the breadcrumbs element output.
We want to use Breadcrumbs with Custom Post Types and we often use URL Rewrites to get the appropriate URL structure in our CPTs.
For example, we have a a CPT “Creators” where the “archive” page is displayed on “site.com/creators” and individual Creator are displayed at “site.com/creator/john-doe”.
I have put “archive” between quotes because it’s not an actual archive page. We use a regular page with a shortcode to display a list of all Creators as it give us more control over the page layout. We then use URL Rewrite to ensure “/creator/” is added in the CPT permalink.
When using the breadcrumbs on the single-page for our CPT, the breadcrumbs will only display “Home > John Doe”, skipping the “Creators” page. Is there a way to add this?
Maybe a custom filter along the lines of…
add_filter( 'tc_edit_breadcrumbs' , 'my_custom_breadcrumbs_structure' );
function my_custom_breadcrumbs_structure {
$current_post_type = $get_post_type($post);
$customslug = array();
if( $current_post_type == "creator" ) {
// Insert custom slug in breadcrumbs
$customslug = array(
"creators" => array(
"target" => "https://www.site.com/creators/",
"index" => 1
)
);
}
return $customslug;
}
… or pushing the idea further you could expand the Breadcrumbs element to allow users to add arbitrary slugs at specific position, which would open some creative ideas using Dynamic Content.
Since I’m pretty sure there’s no such filter, what would be the best approach to achieve the desired result?
Thank you!