Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1114375
    shamrockoz
    Participant

    Support,

    My site link is here

    I would like the breadcrumbs to show up as follows -:

    Home > Blog > Anxiety
    … Instead of …
    Home > Anxiety

    Just aiding with the user UX when they need to drive back to the Blog section, instead of focusing away and clicking on the Blog menu option.

    Ideas?

    #1114943
    Christopher
    Moderator

    Hi there,

    Please add a new category and name it ‘Blog’, then assign ‘Blog’ as Anxiety’s parent category.

    Hope it helps.

    #1115313
    shamrockoz
    Participant

    Support,

    Seems to easy an answer!!!

    So if I do this and someone clicks on the “Blog” category or tag this will drive people back to the Blog page – which is the intent of the question.

    #1115454
    shamrockoz
    Participant

    Support,

    This is not quite what I am looking for … Doing this just drives people back to the “Blog” category page.

    What I am looking for is to drive people back to the actual Blog page – how do I do that?

    #1115520
    Rupok
    Member

    Hi there,

    Thanks for clarifying. I understand what you are trying to achieve. Regretfully, at this time our breadcrumbs don’t support the display of “Blog” as parent of single post in the fashion you’re looking for. This could be possible with custom development, You can follow this thread : https://community.theme.co/forums/topic/blog-page-dont-show-in-breadcrumbs/#post-346314

    Cheers!

    #1115648
    shamrockoz
    Participant

    Thanks Rupok,

    Any ideas how this might work for categories / tags?

    I know that this might be beyond support scope – but the code does not work for categories / tags which is really what I am looking for.

    Any hints within the code?

    #1115886
    Rupok
    Member

    Hi there,

    Thanks for writing back. Usually we can’t assist on such customization as it’s beyond of our support scope. But you can modify the links within elseif ( is_category() ) {} and elseif ( is_tag() ) {}

    Hope this helps.

    #1116045
    shamrockoz
    Participant

    Rupok,

    Done!!

    Perhaps you can vet the code – but – this works way I want it to …

    
         <strong>$blog_link      = 'http://buildatestwpsite.com/blog/';
         $blog_home_url  = '<a href="' . $blog_link .'">' . 'Blog' . '</a>';</strong> 
          
    
          if ( X_WOOCOMMERCE_IS_ACTIVE ) {
            $shop_url   = x_get_shop_link();
            $shop_title = x_get_option( 'x_' . $stack . '_shop_title', __( 'The Shop', '__x__' ) );
            $shop_link  = '<a href="'. $shop_url .'">' . $shop_title . '</a>';
          }
    
          echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
    
            if ( is_home() ) {
    
              echo $current_before . $blog_title . $current_after;
    
            } elseif ( is_category() ) {
    
              $the_cat = get_category( get_query_var( 'cat' ), false );
              if ( $the_cat->parent != 0 ) echo '<a href="'.get_permalink(102).'">'.get_the_title(102) .'</a>';
             
    
    <blockquote> echo  $blog_home_url . $delimiter . $current_before . single_cat_title( '', false ) . $current_after;</blockquote>
    
    
    #1116053
    shamrockoz
    Participant

    Perhaps this should read …

    $blog_link = ‘http://buildatestwpsite.com/blog/&#8217;;
    $blog_home_url = ‘‘ . ‘Blog’ . ‘‘;

    if ( X_WOOCOMMERCE_IS_ACTIVE ) {
    $shop_url = x_get_shop_link();
    $shop_title = x_get_option( ‘x_’ . $stack . ‘_shop_title’, __( ‘The Shop’, ‘__x__’ ) );
    $shop_link = ‘‘ . $shop_title . ‘‘;
    }

    echo ‘<div class=”x-breadcrumbs”>‘ . $home_text . ‘‘ . $delimiter;

    if ( is_home() ) {

    echo $current_before . $blog_title . $current_after;

    } elseif ( is_category() ) {

    $the_cat = get_category( get_query_var( ‘cat’ ), false );
    if ( $the_cat->parent != 0 ) echo ‘‘.get_the_title(102) .’‘;
    echo $blog_home_url . $delimiter . $current_before . single_cat_title( ”, false ) . $current_after;

    #1116055
    shamrockoz
    Participant

    Another try (sigh)

         $blog_link      = 'http://buildatestwpsite.com/blog/';
          $blog_home_url  = '<a href="' . $blog_link .'">' . 'Blog' . '</a>'; 
          
    
          if ( X_WOOCOMMERCE_IS_ACTIVE ) {
            $shop_url   = x_get_shop_link();
            $shop_title = x_get_option( 'x_' . $stack . '_shop_title', __( 'The Shop', '__x__' ) );
            $shop_link  = '<a href="'. $shop_url .'">' . $shop_title . '</a>';
          }
    
          echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
    
            if ( is_home() ) {
    
              echo $current_before . $blog_title . $current_after;
    
            } elseif ( is_category() ) {
    
              $the_cat = get_category( get_query_var( 'cat' ), false );
              if ( $the_cat->parent != 0 ) echo '<a href="'.get_permalink(102).'">'.get_the_title(102) .'</a>';
              echo  $blog_home_url . $delimiter . $current_before . single_cat_title( '', false ) . $current_after;
    
    #1116148
    shamrockoz
    Participant

    Support,

    My changes work fine – however – the breadcrumb appears distorted when you actually pick a post to view …

    I’ll investigate but I just wanted to point this out.

    For example -:

    http://buildatestwpsite.com/youre-okay-but-im-not/

    #1116402
    Lely
    Moderator

    Hi There,

    Thank you for updating us. Can you clarify what you meant by distorted? It is showing fine when I check. Regretfully, at this time I am not entirely certain what it is you would like to accomplish based on the information given in your post. If you wouldn’t mind providing us with a little more clarification on what it is you’re wanting to do (a link to a similar example site would be very helpful, or perhaps some screenshots), we’ll be happy to provide you with a response once we have a better understanding of the situation.

    #1116537
    shamrockoz
    Participant

    Hi Lely,

    Please check now – I made a change to correct it which is what you were seeing. I took out my fix.

    Now you should see what I am talking about.

    This centers around the singular posts where I think it is showing the category name and subcategory. In this case I have no sub-category and it is causing issues.

    All I did was remove the sub category and it works – but you probably may find a better solution

    #1116778
    Rue Nel
    Moderator

    Hello There,

    Please have your code updated and make use of this code instead:

    // Breadcrumbs Display Category Name
    // =============================================================================
    function get_breadcrumb_category( $cat ) {
    GLOBAL $post;
    $post = get_post( $post->ID );
    $post_type = $post->post_type;
    $taxonomy = $cat;
    $f_categories = wp_get_post_terms( $post->ID, $taxonomy );
    $f_category = $f_categories[0];
    if ( $f_category->parent != 0 ) {
    $f_category_id    = $f_category->parent;
    $parent_array     = get_term_by('id', $f_category_id, $taxonomy, 'ARRAY_A');
    $f_category_name  = $parent_array["name"];
    $term_link        = get_term_link( $f_category_id, $taxonomy );
    } else {
    $f_category_id    = $f_category->term_id;
    $f_category_name  = $f_category->name;
    $term_link        = get_term_link( $f_category_id, $taxonomy );
    }
    if ( $f_categories && ! is_wp_error($f_categories) ) {
    return '<a href="' . $term_link . '">' . $f_category_name . '</a>';
    } else {
    return '';
    }
    }
    function x_breadcrumbs() {
    if ( x_get_option( 'x_breadcrumb_display', '1' ) ) {
    GLOBAL $post;
    $is_ltr         = ! is_rtl();
    $stack          = x_get_stack();
    $delimiter      = x_get_breadcrumb_delimiter();
    $home_text      = x_get_breadcrumb_home_text();
    $home_link      = home_url();
    $current_before = x_get_breadcrumb_current_before();
    $current_after  = x_get_breadcrumb_current_after();
    $page_title     = get_the_title();
    $blog_title     = get_the_title( get_option( 'page_for_posts', true ) );
    $blog_url       = get_permalink( get_option( 'page_for_posts', true ) );
    $post_parent    = $post->post_parent;
    $blog_link      = 'http://buildatestwpsite.com/blog/';
    $blog_home_url  = '<a href="' . $blog_link .'">' . 'Blog' . '</a>'; 
    if ( X_WOOCOMMERCE_IS_ACTIVE ) {
    $shop_url   = x_get_shop_link();
    $shop_title = x_get_option( 'x_' . $stack . '_shop_title', __( 'The Shop', '__x__' ) );
    $shop_link  = '<a href="'. $shop_url .'">' . $shop_title . '</a>';
    }
    echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter;
    if ( is_home() ) {
    echo $current_before . $blog_title . $current_after;
    } elseif ( is_category() ) {
    $the_cat = get_category( get_query_var( 'cat' ), false );
    if ( $the_cat->parent != 0 ) echo '<a href="'.get_permalink(102).'">'.get_the_title(102) .'</a>';
    echo $blog_home_url . $delimiter . $current_before . single_cat_title( '', false ) . $current_after;
    } elseif ( x_is_product_category() ) {
    if ( $is_ltr ) {
    echo $shop_link . $delimiter . $current_before . single_cat_title( '', false ) . $current_after;
    } else {
    echo $current_before . single_cat_title( '', false ) . $current_after . $delimiter . $shop_link;
    }
    } elseif ( x_is_product_tag() ) {
    if ( $is_ltr ) {
    echo $shop_link . $delimiter . $current_before . single_tag_title( '', false ) . $current_after;
    } else {
    echo $current_before . single_tag_title( '', false ) . $current_after . $delimiter . $shop_link;
    }
    } elseif ( is_search() ) {
    echo $current_before . __( 'Search Results for ', '__x__' ) . '“' . get_search_query() . '”' . $current_after;
    } elseif ( is_singular( 'post' ) ) {
    if ( get_option( 'page_for_posts' ) == is_front_page() ) {
    $f_category = get_the_category();
    if ( $f_category[0]->category_parent != 0 ) {
    $f_category_id = $f_category[0]->parent;
    $f_category_name = get_cat_name( $f_category_id );
    $f_subcategory_id = $f_category[0]->cat_ID;
    $f_subcategory_name  = get_cat_name( $f_subcategory_id );
    echo '<a href="' . get_category_link( $f_category_id ) . '">' . $f_category_name . '</a>' . $delimiter 
    .'<a href="' . get_category_link( $f_subcategory_id ) . '">' . $f_subcategory_name . '</a>' . $delimiter . $current_before . $page_title . $current_after . $delimiter . '<a href="' . $blog_url . '">' . $blog_title . '</a>';
    } else {
    $f_category_id = $f_category[0]->term_id;
    $f_category_name = $f_category[0]->name;
    echo '<a href="' . get_category_link( $f_category_id ) . '">' . $f_category_name . '</a>' . $delimiter . $current_before . $page_title . $current_after ;
    }
    } else {
    if ( $is_ltr ) {
    $f_category = get_the_category();
    if ( $f_category[0]->category_parent != 0 ) {
    $f_category_id = $f_category[0]->parent;
    $f_category_name = get_cat_name( $f_category_id );
    $f_subcategory_id = $f_category[0]->cat_ID;
    $f_subcategory_name  = get_cat_name( $f_subcategory_id );
    echo '<a href="' . $blog_url . '">' . $blog_title . '</a>' . $delimiter . '<a href="' . get_category_link( $f_category_id ) . '">' . $f_category_name . '</a>' . $delimiter 
    .'<a href="' . get_category_link( $f_subcategory_id ) . '">' . $f_subcategory_name . '</a>' . $delimiter . $current_before . $page_title . $current_after;
    } else {
    $f_category_id = $f_category[0]->term_id;
    $f_category_name = $f_category[0]->name;
    echo '<a href="' . $blog_url . '">' . $blog_title . '</a>' . $delimiter . '<a href="' . get_category_link( $f_category_id ) . '">' . $f_category_name . '</a>' . $delimiter . $current_before . $page_title . $current_after;
    }
    } else {
    echo $current_before . $page_title . $current_after . $delimiter . '<a href="' . get_permalink( get_option( 'page_for_posts' ) ) . '">' . $blog_title . '</a>';
    }
    }
    } elseif ( x_is_portfolio() ) {
    echo $current_before . get_the_title() . $current_after;
    } elseif ( x_is_portfolio_item() ) {
    $link  = x_get_parent_portfolio_link();
    $title = x_get_parent_portfolio_title();
    if ( $v = get_breadcrumb_category('portfolio-category') ) {
    $portfolio_category = $delimiter . $v;
    } else {
    $portfolio_category = '';
    }
    if ( $is_ltr ) {
    echo '<a href="' . $link . '">' . $title . '</a>' . $portfolio_category . $delimiter . $current_before . $page_title . $current_after;
    } else {
    echo $current_before . $page_title . $current_after . $portfolio_category . $delimiter . '<a href="' . $link . '">' . $title . '</a>';
    }
    } elseif ( x_is_product() ) {
    if ( $v = get_breadcrumb_category('product_cat') ) {
    $product_category = $delimiter . $v;
    } else {
    $product_category = '';
    }
    if ( $is_ltr ) {
    echo $shop_link . $product_category . $delimiter . $current_before . $page_title . $current_after;
    } else {
    echo $current_before . $page_title . $current_after . $product_category . $delimiter . $shop_link;
    }
    } elseif ( x_is_buddypress() ) {
    if ( bp_is_group() ) {
    echo '<a href="' . bp_get_groups_directory_permalink() . '">' . x_get_option( 'x_buddypress_groups_title', __( 'Groups', '__x__' ) ) . '</a>' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after;
    } elseif ( bp_is_user() ) {
    echo '<a href="' . bp_get_members_directory_permalink() . '">' . x_get_option( 'x_buddypress_members_title', __( 'Members', '__x__' ) ) . '</a>' . $delimiter . $current_before . x_buddypress_get_the_title() . $current_after;
    } else {
    echo $current_before . x_buddypress_get_the_title() . $current_after;
    }
    } elseif ( x_is_bbpress() ) {
    remove_filter( 'bbp_no_breadcrumb', '__return_true' );
    if ( bbp_is_forum_archive() ) {
    echo $current_before . bbp_get_forum_archive_title() . $current_after;
    } else {
    echo bbp_get_breadcrumb();
    }
    add_filter( 'bbp_no_breadcrumb', '__return_true' );
    } elseif ( is_page() && ! $post_parent ) {
    echo $current_before . $page_title . $current_after;
    } elseif ( is_page() && $post_parent ) {
    $parent_id   = $post_parent;
    $breadcrumbs = array();
    if ( is_rtl() ) {
    echo $current_before . $page_title . $current_after . $delimiter;
    }
    while ( $parent_id ) {
    $page          = get_page( $parent_id );
    $breadcrumbs[] = '<a href="' . get_permalink( $page->ID ) . '">' . get_the_title( $page->ID ) . '</a>';
    $parent_id     = $page->post_parent;
    }
    if ( $is_ltr ) {
    $breadcrumbs = array_reverse( $breadcrumbs );
    }
    for ( $i = 0; $i < count( $breadcrumbs ); $i++ ) {
    echo $breadcrumbs[$i];
    if ( $i != count( $breadcrumbs ) -1 ) echo $delimiter;
    }
    if ( $is_ltr ) {
    echo $delimiter . $current_before . $page_title . $current_after;
    }
    } elseif ( is_tag() ) {
    echo $blog_home_url . $delimiter . $current_before . single_tag_title( '', false ) . $current_after;
    } elseif ( is_author() ) {
    GLOBAL $author;
    $userdata = get_userdata( $author );
    echo $current_before . __( 'Posts by ', '__x__' ) . '“' . $userdata->display_name . $current_after . '”';
    } elseif ( is_404() ) {
    echo $current_before . __( '404 (Page Not Found)', '__x__' ) . $current_after;
    } elseif ( is_archive() ) {
    if ( x_is_shop() ) {
    echo $current_before . $shop_title . $current_after;
    } else {
    echo $current_before . __( 'Archives ', '__x__' ) . $current_after;
    }
    }
    echo '</div>';
    }
    }

    Please let us know if this works out for you.

    #1116793
    shamrockoz
    Participant

    Rue,

    This works as expected – do you mind sharing what you changed?

    Like to learn from the excellent support I receive!

  • <script> jQuery(function($){ $("#no-reply-1114375 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>