• Resolved ldpr

    (@ldprecords)


    Hi,
    I have been trying to find a good php code way to display the Storefront breadcrumbs on my single product pages only, with no luck. As I don’t want them to show on remaining parts of my shop, I have currently disabled them altogether.
    Is there an easy way to exclude all sections aside the single product pages on display?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Roxy

    (@roxannestoltz)

    Hi @ldprecords ,

    Thanks for reaching out!

    I understand that you would like to display breadcrumbs on Single product pages only, is this correct?

    Since there is no default option within WooCommerce core that will allow you to achieve this, as you mentioned, custom code will be required.

    I have tested the below custom code on my staging site which uses the latest version of WordPress and WooCommerce and has the default Storefront theme active, and it is working as expected.

    You can enable all breadcrumbs on your site, and then try the following code snippet to see if this works for you:

    add_action( 'storefront_before_content', 'wc_remove_storefront_breadcrumbs', 0);
    
    function wc_remove_storefront_breadcrumbs() {
      if( !is_product() ) {
       remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
      }
    }

    You need to add the code to your child theme’s?functions.php?file or via a plugin that allows custom functions to be added, such as the?Code snippets?plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

    Since custom code is beyond the scope of support we are able to provide, should the code not work as expected on your end, I will leave this open to see if anyone else can chime in with another solution.

    Hope this helps ??

    Thread Starter ldpr

    (@ldprecords)

    It did indeed! Thank you so much Roxy ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Storefront breadcrumbs on single product pages only’ is closed to new replies.