In order to remove breadcrumbs from the Storefront theme, the documentation states to add the following in functions.php:
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
I tried this in a child theme of Storefront and it doesn't work. Tracing back the woocommerce_breadcrumb, it seems to be added in storefront_content_top action (in the file <storefront_dir>/inc/woocommerce/storefront-woocommerce-template-hooks.php. I commented out the corresponding line and indeed the breadcrumbs are hidden.
However, to do this the right way, I try to disable it from the child theme using
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
but it doesn't work. I should clarify that I test this in a fresh child theme with no other code.
How would one disable the breadcrumbs from a child theme?
Copy and paste the following snippet into your functions.php file.
add_action( 'init', 'z_remove_wc_breadcrumbs');
function z_remove_wc_breadcrumbs() {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10);
}
since Storefront 2.3.1 try this
add_action('init', 'dp_remove_wc_breadcrumbs');
function dp_remove_wc_breadcrumbs(){
remove_action('storefront_before_content', 'woocommerce_breadcrumb', 10);
};
Try this:
add_filter( ‘woocommerce_get_breadcrumb’, ‘__return_false’ );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
.breadcrumb{
display: none;
}
Related
In WooCommerce we want to disable the product image zoom on hover. I've seen multiple options to do it in the child theme, functions.php. But they all are not working.
The child theme function.php is working (has some other code in it that is working). It's also not working when I put it in the main theme function.php file.
I've tried:
add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
and
function remove_image_zoom_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
add_action( 'wp', 'remove_image_zoom_support', 100 );
and
add_filter( ‘woocommerce_single_product_zoom_options’, ‘custom_single_product_zoom_options’, 10, 3 );
function custom_single_product_zoom_options( $zoom_options ) {
// Disable zoom magnify:
$zoom_options[‘magnify’] = 0;
return $zoom_options;
}
Any more options?
All the given options don't work. The theme has a (hidden) builtin feature for this.
Thanks for the replies.
I would like to change position of Add to Cart Button on Single Product. I've tried to used code below:
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 9);
Unfortunately it doesn't work with My Theme. The result is that Add to Cart Button is double. The screenshot below:
Add cart button displaying twice with My Theme
When I change the Theme to different one (Twenty Nineteen), every thing seems to be okey. The screenshot below:
Add car button displaying once with Twenty Nienteen Theme
My website is www.applefix.pl. Please help me with that.
Maybe you could try to "delay" the actions after the parent theme is loaded:
function wc_move_single_product_button() {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 9);
};
add_action( 'after_setup_theme', 'wc_move_single_product_button', 20 );
Update: another possibility is that your theme uses another function to hook the button. I would try to use the WordPress default theme just to check if that’s the case. If it is, you can search the function and unhook it properly!
Let me know if it does the trick!
I want to remove the Sort by dropdown completely, in my WooCommerce installation.
http://cswpstage.hostworks.net/product-category/memorabilia/signed-photos/
Thanks!
It depends on the theme that you're using. There are two approaches, CSS and PHP.
I see on your theme you have already hidden it via CSS using
.sort-param-order,
.sort-param-sort {
display: none;
}
If you want to hide it with PHP, you need to look for the action which adds it and remove that action. A search for woocommerce_catalog_ordering will generally return the action you're looking for.
Here is how you remove it via standard WooCommerce:
<?php
/**
* Remove sorting from WooCommerce.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}
add_action( 'init', 'thenga_remove_filtering' );
And here is how you remove it from the Storefront theme:
<?php
/**
* Remove sorting from Storefront.
*/
function thenga_remove_filtering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
}
add_action( 'init', 'thenga_remove_filtering' );
Can one help me to remove the customizer section in genesis. i want to remove color section from the theme customizer in genesis.tried many code but now working. can anyone help me with code
add_action( 'customize_register', 'wpse8170_customize_register' );
function wpse8170_customize_register( WP_Customize_Manager $wp_customize ) {
$wp_customize->remove_section('id-of-section');
}
I had trouble with this too, until I found this code. Just stick it in your functions.php
// Removing Genesis Sections from Customizer page
add_action( 'customize_register', 'gd_remove_customize_section', 20 );
function gd_remove_customize_section($wp_customize){
$wp_customize->remove_section( 'genesis_layout');
$wp_customize->remove_section( 'genesis_breadcrumbs');
$wp_customize->remove_section( 'genesis_comments');
$wp_customize->remove_section( 'genesis_archives');
}
I have difficulty doing this even after following instructions of how to do it. I don't know if the structure of woocommerce have changed since the below snippet was given.
Below is the code I tried using to remove the Add to cart button in the Homeapage and Shop page.
Mind you, this was pasted in the Theme Functions (functions.php) and I use MyStile Theme.
I was able to remove the Add to Cart button from the single page but not the homepage and shop page.
Code
function remove_loop_button(){
remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
}
add_action('init', 'remove_loop_button');
Thanks for your help in advance.
You can use following code. Put it in your functions.php:
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
To Remove “Add to Cart” button all you need to do is paste the following lines of code in your functions.php file located inside your theme’s directory.
//remove "Add to Cart" button on product listing page in WooCommerce
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}