Home › Forums › Gillion Theme › Breadcrumb not supporting custom posts properly
Home › Forums › Gillion Theme › Breadcrumb not supporting custom posts properly
Hi,
I’m using the plugin Geodirectory which generates custom post types, however the bread crumb is not generated properly . The bread crumb is doing this: “Home > gt_projecten” and should do “Home > Projecten” which is generated correctly when going 1 level deeper. Please see below examples.
Hi @dirkvang,
I hope you are well today and thank you for your question.
I could confirm it on your shared website.
Would you mind if I log in to your site and do quick troubleshooting? If this is ok then could you please temporarily create an admin user account and share me the account login details privately by adding them in the box having text “Enter your private content here (only you and forum moderators will be able to see it)”?
Best regards,
Shufflehound team
Yes ofc here you go
I logged into your website but didn’t have privileges to edit child theme file.
To resolve the issue, you have to add the below code in the functions.php file of the child theme.
function gillion_breadcrumbs( $args = array() ) { // Do not display on the homepage // Set default arguments $defaults = array( 'separator_icon' => '>', 'breadcrumbs_id' => 'breadcrumbs', 'breadcrumbs_classes' => 'breadcrumb-trail breadcrumbs', 'home_title' => esc_html__( 'Home', 'gillion' ), ); // Parse any arguments added $args = apply_filters( 'ct_ignite_breadcrumbs_args', wp_parse_args( $args, $defaults ) ); // Set variable for adding separator markup $separator = '<span class="separator"> ' . esc_attr( $args['separator_icon'] ) . ' </span>'; // Get global post object global $post; /***** Begin Markup *****/ // Open the breadcrumbs $html = '<div id="' . esc_attr( $args['breadcrumbs_id'] ) . '" class="' . esc_attr( $args['breadcrumbs_classes']) . '">'; // Add Homepage link & separator (always present) $html .= '<span class="item-home">' . esc_attr( $args['home_title'] ) . '</span>'; if ( !is_front_page() ) { $html .= $separator; } // Post if ( is_front_page() ) { //return; } elseif ( is_singular( 'post' ) ) { // Get post category info $category = get_the_category(); // Get category values $category_values = array_values( $category ); // Get last category post is in $last_category = end( $category_values ); // Get parent categories $cat_parents = rtrim( (string)get_category_parents( $last_category->term_id, true, ',' ), ',' ); // Convert into array $cat_parents = explode( ',', $cat_parents ); // Loop through parent categories and add to breadcrumb trail foreach ( $cat_parents as $parent ) { $html .= '<span class="item-cat">' . wp_kses( $parent, wp_kses_allowed_html( 'a' ) ) . '</span>'; $html .= $separator; } // add name of Post $html .= '<span class="item-current item-' . $post->ID . '"><span class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</span></span>'; } // Page elseif ( is_singular( 'page' ) ) { // if page has a parent page if ( $post->post_parent ) { // Get all parents $parents = get_post_ancestors( $post->ID ); // Sort parents into the right order $parents = array_reverse( $parents ); // Add each parent to markup foreach ( $parents as $parent ) { $html .= '<span class="item-parent item-parent-' . esc_attr( $parent ) . '">' . get_the_title( $parent ) . '</span>'; $html .= $separator; } } // Current page $html .= '<span class="item-current item-' . $post->ID . '"><span title="' . get_the_title() . '"> ' . get_the_title() . '</span></span>'; } // Attachment elseif ( is_singular( 'attachment' ) ) { // Get the parent post ID $parent_id = $post->post_parent; // Get the parent post title $parent_title = get_the_title( $parent_id ); // Get the parent post permalink $parent_permalink = get_permalink( $parent_id ); // Add markup $html .= '<span class="item-parent">' . esc_attr( $parent_title ) . '</span>'; $html .= $separator; // Add name of attachment $html .= '<span class="item-current item-' . $post->ID . '"><span title="' . get_the_title() . '"> ' . get_the_title() . '</span></span>'; } // Custom Post Types elseif ( is_singular() ) { // Get the post type $post_type = get_post_type(); // Get the post object $post_type_object = get_post_type_object( $post_type ); // Get the post type archive $post_type_archive = get_post_type_archive_link( $post_type ); // Add taxonomy link and separator $html .= '<span class="item-cat item-custom-post-type-' . esc_attr( $post_type ) . '">labels->name ) . '">' . esc_attr( $post_type_object->labels->name ) . '</span>'; $html .= $separator; // Add name of Post $html .= '<span class="item-current item-' . $post->ID . '"><span class="bread-current bread-' . $post->ID . '" title="' . $post->post_title . '">' . $post->post_title . '</span></span>'; } // Category elseif ( is_category() ) { // Get category object $parent = get_queried_object()->category_parent; // If there is a parent category... if ( $parent !== 0 ) { // Get the parent category object $parent_category = get_category( $parent ); // Get the link to the parent category $category_link = get_category_link($parent); // Output the markup for the parent category item $html .= '<span class="item-parent item-parent-' . esc_attr( $parent_category->slug ) . '">slug ) . '" href="' . esc_url( $category_link ) . '" title="' . esc_attr( $parent_category->name ) . '">' . esc_attr( $parent_category->name ) . '</span>'; $html .= $separator; } // Add category markup $html .= '<span class="item-current item-cat"><span class="bread-current bread-cat" title="' . $post->ID . '">' . single_cat_title( '', false ) . '</span></span>'; } // Tag elseif ( is_tag() ) { // Add tag markup $html .= '<span class="item-current item-tag"><span class="bread-current bread-tag">' . single_tag_title( '', false ) . '</span></span>'; } // Author elseif ( is_author() ) { // Add author markup $html .= '<span class="item-current item-author"><span class="bread-current bread-author">' . get_queried_object()->display_name . '</span></span>'; } // Day elseif ( is_day() ) { // Add day markup $html .= '<span class="item-current item-day"><span class="bread-current bread-day">' . get_the_date() . '</span></span>'; } // Month elseif ( is_month() ) { // Add month markup $html .= '<span class="item-current item-month"><span class="bread-current bread-month">' . get_the_date( 'F Y' ) . '</span></span>'; } // Year elseif ( is_year() ) { // Add year markup $html .= '<span class="item-current item-year"><span class="bread-current bread-year">' . get_the_date( 'Y' ) . '</span></span>'; } // Custom Taxonomy elseif ( is_archive() ) { // get the name of the taxonomy $custom_tax_name = get_queried_object()->display_name; // Add markup for taxonomy $html .= '<span class="item-current item-archive"><span class="bread-current bread-archive">' . esc_attr($custom_tax_name) . '</span></span>'; } // Search elseif ( is_search() ) { // Add search markup $html .= '<span class="item-current item-search"><span class="bread-current bread-search">'. esc_html__( 'Search results for', 'gillion' ) .': ' . get_search_query() . '</span></span>'; } // 404 elseif ( is_404() ) { // Add 404 markup $html .= '<span>' . esc_html__( 'Error 404', 'gillion' ) . '</span>'; } elseif( is_home() && isset( $_GET['read-it-later'] ) ) { // Add read later markup $html .= '<span>' . esc_html__( 'Read It Later', 'gillion' ) . '</span>'; } else { $html .= '<span class="item-current"><span class="bread-current">' . esc_attr( get_the_title( gillion_page_id() ) ) . '</span></span>'; } // Close breadcrumb container $html .= '</div>'; apply_filters( 'ct_ignite_breadcrumbs_filter', $html ); return ( $html ); }
Hi, thanks for that. I heard from the team of GeoDirectory when I asked them first (since I thought the breadcrumb was managed by them) that the issue lies in the theme, they say: “Its a theme issue. The theme is displaying CPT name at line #1106. Instead, one should use the CPT label. Then it works.”
They changed it in my theme and now it works. However when the theme will be updated it will be overwritten. It seems to be a very small change in the theme. Would that be possible to fix in the next version, instead of the additional functions.php changes?
Yes, i have notified the theme developer to change it in the future version of the theme.
Thanks a lot!
You are most welcome here 🙂
Solution for this topic
The issue is resolved in the below latest version of theme so please update the theme as described here https://support.shufflehound.com/updating-theme/
Please login to access this file
thanks that works!
You are always welcome here 🙂