Okay
  Public Ticket #1706861
I want to show breadcrumbs on product archive page and have them match other pages for position / style
Closed

Comments

  •  1
    thscreative started the conversation

    Hi there

    I managed to get breadcrumbs to show on my shop page, they didn't by default. 

    The problem is I want them to be in the same position as they are on the other pages (top right on the page) for example single product pages: https://voicebullet.co.uk/product/family-bible/ I used the hook woocommerce_before_main_content. Maybe there is a simpler way in the settings that I can't find?

    I would also like to show breadcrumbs on posts and single custom posts but am not quite sure how.

    Very grateful for any help

  • [deleted] replied

    Hi thscreative,

    If you want to show the breadcrumb on shop archive page please add this code in functions.php (because it is not implemented yet in theme options):

    // Breadcrumb in shop
    function shop_archive_breadcrumb() {
        if ( is_product_category() || is_product_tag() || is_shop() ) :
            ?>
            <style>
                .show-archive-breadcrumb {
                    margin-top: 10px;
                    text-align: right;
                    position: relative;
                    top: 20px;
                }
            </style>
            <div class="container show-archive-breadcrumb">
                <div class="row">
                    <div class="col-sm-12">
                        <?php echo aurum_page_heading_breadcrumb(); ?>
                    </div>
                </div>
            </div>
        <?php
        endif;
    }
    add_action( 'woocommerce_before_main_content', 'shop_archive_breadcrumb', 1 );

    As for breadcrumb in pages you can enable it (it is enabled by default) if plugin Breadcrumb NavXT is active:


    (view large version)

    For each specific page/post item.

  •  1
    thscreative replied

    Thanks, brilliant. That did the trick for the shop. 

    How could I do the same for the blog (posts) and also custom post type single and archive pages?

  •  1
    thscreative replied

    ...Further to what I said below – my blog archive page is a 'page' and I have the NavXT plugin installed and the show breadcrumb option ticked but it appears to be using the home.php template

  • [deleted] replied

    Hi,

    I am not sure why it is not showing the breadcrumb on that page, I have added this code:

    // Show breadcrumb on blog page
    function visible_breadcrumb_on_blog_page( $visible ) {
        if ( is_home() || is_archive() ) {
            return true;
        }
        
        return $visible;
    }
    add_filter( 'aurum_page_heading_visibility', 'visible_breadcrumb_on_blog_page', 1000 );
    

    In functions.php and it is showing now.

  •  1
    thscreative replied

    Thank you that worked for the blog archive page

    I'm afraid it still doesn't show for single posts, single custom posts (post type slug 'writers' – single-writers.php template) or single pages (see example: https://voicebullet.co.uk/events/the-elizabeth-garrett-anderson-gallery/?wcs_timestamp=1533114000 - which uses the page.php template ).

    I'd like them to be universal ideally.

    One other issue I have is that the page title is always hidden and I'm not too sure how to make it show

    Many thanks for your help

  • [deleted] replied

    Hi,

    I have overridden the breadcrumb function and removed the condition that checks if breadcrumbs are enabled to be shown, so now they are by default shown on all pages (except homepage):

    BEFORE:


    (view large version)

    NOW:


    (view large version)

    I hope you like it now. Sorry for your waiting.

  •  1
    thscreative replied

    Hi Arlind, I'm really sorry but something has happened to my site and I have lost your amendments below. Can you let me know where I need to add this code in order to get the breadcrumbs back?

    Many thanks

    Chris

  • [deleted] replied

    Hi Chris,

    No worries, here is the code I have added in functions.php of Child Theme and it turned to work:

    function aurum_page_heading_breadcrumb() {
        $post_id = get_queried_object_id();
        
        $breadcrumb = aurum_breadcrumb( true );
        
        if ( $breadcrumb ) {
            return "<div class="\"right-aligned\"">{$breadcrumb}</div>";
        }
        
        return '';
    }
    
    This should work for you.

  •  2
    Lloyd_Vanacker replied

    Hi Arlind... I see this subject is closed but I can't manage to get the breadcrumb on all the category pages... It is showing on the shop page but the trail between the single product and the shop page is missing...

    This is the modified code I used....

    function visible_breadcrumb( $visible ) {
        if ( is_product_category() || is_product_tag() || is_shop() ) {
            return true;
        }
        return $visible;
    }
    add_filter( 'aurum_page_heading_visibility', 'visible_breadcrumb', 1000 );

  • [deleted] replied

    Hi Lloyd_Vanacker,

    If you have Child theme activated simply add this code in functions.php

    function aurum_page_heading_breadcrumb() {
        $post_id = get_queried_object_id();
        
        $breadcrumb = aurum_breadcrumb( true );
        
        if ( $breadcrumb ) {
            return '<div class="right-aligned">{$breadcrumb}</div>';
        }
        
        return '';
    }
    

    This should work for you.

  •  2
    Lloyd_Vanacker replied

    Hi Arlind,


    thank you. The breadcrumb is visible but it's showing as

    {$breadcrumb}

    :(

  • [deleted] replied

    Ah sorry, please remove that code and add this one:

    function aurum_page_heading_breadcrumb() {
        $post_id = get_queried_object_id();
        
        $breadcrumb = aurum_breadcrumb( true );
        
        if ( $breadcrumb ) {
            return '<div class="right-aligned">' . $breadcrumb . '</div>';
        }
        
        return '';
    }
    
    This will display the breadcrumb.

  •  2
    Lloyd_Vanacker replied

    Hi,

    I've just figured that one out. That one works. Thanks for the great/quick support!!!

  • [deleted] replied

    Glad to hear that Lloyd.

    I wish you a great day!

    P.S: If you like the theme, it would help us a lot if you could give us a five-star rating on Themeforest from your Downloads tab.

    A huge thank you from Laborator in advance.