• Resolved James

    (@en7jos)


    Hi,

    Thought this should be simple, but can’t find a solution anywhere after hours of searching so here goes…

    What I want to do is remove the default WooCommerce breadcrumbs and instead replace these with the WordPress SEO (Yoast) breadcrumbs. I have Yoast breadcrumbs on the rest of the site and would like to continue the same layout, structure and styling on the ecommerce pages too.

    I have Yoast breadcrumbs working fine elsewhere, but can’t figure how to get them to show up on the WooCommerce pages. I found an article about replacing WooTheme breadcrumbs with Yoast ones (see here), but this doesn’t work (i.e. no effect) for Woocommerce.

    Any ideas please?

    Thanks, James

    https://www.ads-software.com/extend/plugins/wordpress-seo/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter James

    (@en7jos)

    Ok, I think I’ve figured out a solution!

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    // Remove default WooCommerce breadcrumbs and add Yoast ones instead
    remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
    add_action( 'woocommerce_before_main_content','my_yoast_breadcrumb', 20, 0);
    if (!function_exists('my_yoast_breadcrumb') ) {
    	function my_yoast_breadcrumb() {
    		yoast_breadcrumb('<p id="breadcrumbs">','</p>');
    	}
    }

    Very pleased with myself for that ??

    The first line of code removed the default WooCommerce breadcrumbs from all pages, then the other lines add in the Yoast ones in their place with the necessary formatting to keep them looking the same as the rest of the site.

    This goes in the custom functions.php of my theme.

    Where did you place these lines of code?

    Thread Starter James

    (@en7jos)

    The above code went in my themes custom ‘functions.php’ file. Go to Appearnace > Editor in the menu, select your theme and then the custom functions file. Guess the details vary depending upon your theme and setup, but for me, functions.php is a file for pasting just this sort of over-ride code.

    Hope that helps…. James

    Hi,

    I use Woocommerce on WordPress and want to get the YOAST breadcrumbs. To be honest, not sure why. What is the benefit over the standard breadcrumbs which look pretty good to me?

    I did what you did but only got the breadcrumbs on the product pages. How can I get them also on the other pages?

    Hope you can help me.

    Thread Starter James

    (@en7jos)

    Jantjebeton – the advantage for me of Yoast breadcrumbs over the standard ones is that you have more control over the way they are displayed. You can set the breadcrumb text for a given post / page (see the Advanced tab under the ‘WordPress SEO by Yoast’ settings on each page / post edit screen) so the breadcrumb is not fixed as the page / post title. So you can neaten the breadcrumb trail up considerably.

    Also, in my theme I found that the WooCommerce breadcrumbs were different to the WP ones elsewhere on my site in terms of layout, separator, style and format. By using the Yoast ones everywhere I got consistency of design and format.

    To add the Yoast breadcrumbs to all the other pages, follow the instructions on the ‘Internal Links’ section of the Yoast plugin settings in your WP admin area. There’s some code that you need to add to your templates to get the breadcrumbs to show on the non-WC pages too.

    Hope that helps… James

    Thank you so much for the code.

    Unfortunately I have problems at my product pages:
    Fatal error: Call to undefined function yoast_breadcrumb() in /home/renatfb56/domains/haardonutkopen.nl/public_html/wp-content/themes/mystileori/mystile/functions.php on line 55

    Does somebody have a solution for this problem?

    Thread Starter James

    (@en7jos)

    Do you have the WordPress SEO plugin installed and Yoast Breadcrumbs activated within that? See here:
    https://www.ads-software.com/extend/plugins/wordpress-seo/

    Hi James. Just to thank you for this solution. Managed to replace it with Yoast’s breadcrumbs.

    Just on the off-chance that someone is using Thesis theme (2.x), just put the code into: Theme Functions (functions.php).

    This code would go into Functions.php on almost any theme!

    The code that @james wrote works great.

    I use yoasts breadcrumbs because they also include structured data which helps to get indexed nicely.

    Yoast bredcrumbs not working: I have tried adding:
    // Remove default WooCommerce breadcrumbs and add Yoast ones instead
    remove_action( ‘woocommerce_before_main_content’,’woocommerce_breadcrumb’, 20, 0);
    add_action( ‘woocommerce_before_main_content’,’my_yoast_breadcrumb’, 20, 0);
    if (!function_exists(‘my_yoast_breadcrumb’) ) {
    function my_yoast_breadcrumb() {
    yoast_breadcrumb(‘<p id=”breadcrumbs”>’,'</p>’);
    }
    }
    to my functions.php page, but the woocommerce breadcrumbs are still there.
    I have SEO Yoast plugin installed, used internal links settings to create yoast breadcrumbs..NOTHING works. Any help would be greatly appreciated.
    I’m about to lose it..

    Thread Starter James

    (@en7jos)

    The above code to remove the default Woo breadcrumbs and replace them with the Yoast ones is no longer working for me either ?? I just can’t seem to get rid of the Woo breadcrumbs, suspect this is something to do with my theme (Striking) since I think it happened after I installed an update which included some new breadcrumb functionality.

    Still trying to figure it out…. will report back if I find anything.

    julester75

    (@julester75)

    My functions.php file states categorically:

    <?php
    /*
    WARNING: This file is part of the core PrimaThemes framework.
    DO NOT edit this file under any circumstances.
    Please do all modifications in the form of a child theme.
    */
    require_once( TEMPLATEPATH.’/core/functions/setup.php’ );

    With this being the case, any ideas where I should put this code? I also want to hide the search form from the bottom of my shop/products pages too, so advice on code to achieve this would be much appreciated…

    Leon Korteweg

    (@lkorteweghayonanl)

    Put this in the functions.php of your child theme:

    // Replace WooThemes Breadcrumbs with Yoast breadcrumbs
    add_action( 'init', 'mp_breadcrumbs' );
    function mp_breadcrumbs() {
        remove_action( 'woo_loop_before', 'woo_breadcrumbs', 10 );
        add_action( 'woo_loop_before','mp_yoast_breadcrumb', 20, 0);
        function mp_yoast_breadcrumb() {
            if ( function_exists('yoast_breadcrumb')  && !is_front_page() ) {
                yoast_breadcrumb('<p class="breadcrumbs">','</p>');
            }
        }
    
    }

    not working for me – not even with the yoast woocommerce seo paid extension – have written to support and waiting for their reply

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Replacing WooCommerce breadcrumbs with Yoast SEO ones’ is closed to new replies.