Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionI have a product description which is hooked into my product archive page in the following way by my theme (The7):
/**
* display short desc hook.
*
* @hooked woocommerce_template_loop_rating - 5
* @hooked woocommerce_template_loop_price - 10
*/
do_action( 'woocommerce_shop_loop_item_desc' );
In my template setting, I have a way of hiding this product description but this just hides the div with the description by using CSS display: none;
This is not good, as in the background, the description is still loaded & this has a negative effect on the performance of the page.
Therefore, I want to remove the action. I now did it by commenting it in the template file, but everytime I update the theme I'm screwed.
I tried to remove the action by adding the following code in my functions.php
file (source: ) but this did not work:
/* Remove product description on product archive page */
remove_action( 'woocommerce_template_loop_rating','woocommerce_shop_loop_item_desc', 5);
remove_action( 'woocommerce_template_loop_price','woocommerce_shop_loop_item_desc', 10);
Anybody has an idea on how to correctly remove the action?
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionI have a product description which is hooked into my product archive page in the following way by my theme (The7):
/**
* display short desc hook.
*
* @hooked woocommerce_template_loop_rating - 5
* @hooked woocommerce_template_loop_price - 10
*/
do_action( 'woocommerce_shop_loop_item_desc' );
In my template setting, I have a way of hiding this product description but this just hides the div with the description by using CSS display: none;
This is not good, as in the background, the description is still loaded & this has a negative effect on the performance of the page.
Therefore, I want to remove the action. I now did it by commenting it in the template file, but everytime I update the theme I'm screwed.
I tried to remove the action by adding the following code in my functions.php
file (source: https://codex.wordpress/Function_Reference/remove_action) but this did not work:
/* Remove product description on product archive page */
remove_action( 'woocommerce_template_loop_rating','woocommerce_shop_loop_item_desc', 5);
remove_action( 'woocommerce_template_loop_price','woocommerce_shop_loop_item_desc', 10);
Anybody has an idea on how to correctly remove the action?
Share Improve this question edited Apr 6, 2019 at 18:48 rudtek 6,3835 gold badges30 silver badges52 bronze badges asked Apr 5, 2019 at 8:55 BarrieOBarrieO 992 silver badges12 bronze badges 5 |1 Answer
Reset to default 2First thing, regarding your comment "everytime I update the theme I'm screwed" - you should always use a child theme when doing any customisations .
Second, your remove_action
call is wrong. As per the documentation you've linked to already, it sates that the first argument is $tag
and the second is $function_to_remove
. Right now, your arguments are reversed.
So the correct call would be
/* Remove product description on product archive page */
remove_action( 'woocommerce_shop_loop_item_desc', 'woocommerce_template_loop_rating', 5);
remove_action( 'woocommerce_shop_loop_item_desc', 'woocommerce_template_loop_price', 10);
Update:
if the above solution doesn't work, it might be because the hook triggers after theme setup. In this case you can try the following :
add_action( 'after_setup_theme', 'my_remove_parent_theme_stuff', 0 );
function my_remove_parent_theme_stuff() {
remove_action( 'woocommerce_shop_loop_item_desc', 'woocommerce_template_loop_rating', 5);
remove_action( 'woocommerce_shop_loop_item_desc', 'woocommerce_template_loop_price', 10);
}
woocommerce_shop_loop_item_desc
as a hook and to remove you usedwoocommerce_shop_loop_item_desc
as function. You probably have some other function hooked into thewoocommerce_shop_loop_item_desc
. – Karun Commented Apr 5, 2019 at 9:34