-
-
Save lukecav/48f367e68ec5db914f604f53a789a59e to your computer and use it in GitHub Desktop.
// Remove Links to WooCommerce Single Product Page | |
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 ); | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 ); |
Try this:
function remove_direct_link_to_product_page() { if ( is_product() && is_product_category(array('category-slug') ) ) { remove_action( ‘woocommerce_before_shop_loop_item’, ‘woocommerce_template_loop_product_link_open’, 10 ); remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_product_link_close’, 5 ); } }
Hi!
this code works for most themes including storefront, but i just cannot make it work for oceanwp theme.
Can anyone help me with that, I tried all solutions from all threads over the net , no one works. Please help!
In that case I would check for similar issue in the WP org repo for the OceanWP theme or create a new one.
https://wordpress.org/support/theme/oceanwp/
Thank you!
i did that, but i don't think someone will ever respond :(
Thanks!
Adding the above code has removed the links from products.
However, I want to target only a specific category and tried the following and didn’t work, (I’ve probably got it coded wrong) any thoughts about this?
function remove_direct_link_to_product_page() {
if ( is_product_category( ‘category-slug’ ) ) {
remove_action( ‘woocommerce_before_shop_loop_item’, ‘woocommerce_template_loop_product_link_open’, 10 );
remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_product_link_close’, 5 );
}
}