Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @jackmgm,

    You can do this by adding these below codes in your theme functions.php file :

    // Disable single product link on shop 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 );

    This will disable link of single product on shop page.

    Regards

    Thread Starter jackmgm

    (@jackmgm)

    Hi, thanks for this however, it just seems to make the page crash?

    Hello @jackmgm,

    First activate your wordpress latest default theme and test this code by pasting above solution in your theme functions.php file.This will not make page crash.provided solution is well tested.
    Try once and if still you face issue please let us know.

    Regards

    Thread Starter jackmgm

    (@jackmgm)

    Hi, it still won’t work, I can’t seem to find a solution.

    @wbcomdesigns adding the above code has removed the links from products.
    However, I want to target only a specific category. Tried the following and didn’t work:

    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 );
    }
    }

    (I’ve probably got it coded wrong) any thoughts about this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do I disable single product pages.’ is closed to new replies.