Tagged: breadcrumbs, custom, enfold
Hi,
We have a main landing page that teases a collection of custom single post types (a total of 6 different CPTs), with each Post linking to its respective single Post page.
On the single Post pages, the breadcrumbs are currently displaying as such:
You are here: Home / [custom post type slug ] / Single Custom Post Title Name
For example…
You are here: Home / Memories with a Photo / “This is my Memory Title”
The “Home” link leads to the home page, whereas the middle section (Memories with a Photo) leads to the ‘archive’ page for that Custom Post Type.
I need to replace the middle section of the breadcrumbs for all 6 of these CPTs. I imagine I need to edit the enfold > framework > php > class-breadcrumbs.php file but I do not know exactly where or how.
I am using a child theme if that helps.
Please advise.
thanks!
Hi raisonbrands!
Thank you for using Enfold.
Can you please provide a link to one of the cpt single post page? Use this in the functions.php file:
add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb_cat', 20, 1);
function avia_change_breadcrumb_cat($trail) {
if(is_singular( array( 'newspaper', 'book', 'anothercpt', 'cptagain' ) ))
{
$page = get_post(2);
$trail[1] = '<a href="' . $page->guid . '" title="' . esc_attr( $page->post_title ) . '">' . esc_attr( $page->post_title ) . '</a>';
}
return $trail;
}
Change the id in the get_post to the id of the page where the cpt resides and add the cpt name in the is_singular array.
Cheers!
Ismael
Thank you so much! Quick and effective response that worked perfectly the first time!!