• Resolved davidias244

    (@davidias244)


    I’m trying to make all my products to open in a new tab.
    I tried inserting the following code that I found here in the “functions.php” but it didn’t work for me:

    remove_action( ‘woocommerce_before_shop_loop_item’,’woocommerce_template_loop_product_link_open’, 10 );
    add_action ( ‘woocommerce_before_shop_loop_item’, ‘ami_function_open_new_tab’, 10 );
    function ami_function_open_new_tab() {
    echo ‘‘;
    }

    I tried it in 4 different themes but it didn’t work in none of them.

    Thanks!!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,

    You have custom class thumb in product listing. So, you can try with below code

    In ami_function_open_new_tab() >> a href you can use class=”thumb”

    Please let me know if this is working for you.

    Thanks!

    Please try below code if above will not work

    jQuery(document).ready(function($){
    $(‘.products .thumbnail-wrapper’).each(function(){
    $(this).find(‘a’).attr(‘target’, ‘_blank’ );
    });
    });

    Please keep this in your child theme JS file.

    Thanks!

    Thread Starter davidias244

    (@davidias244)

    Hey man, thanks for the answer.
    I’m sorry but I don’t know how to put the class=”thumb” inside the code I have.

    And about the second code, none of the child themes have any JS files, just function.php and style.css.

    Thanks for the help!

    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    Since this is a few weeks old without help in customization, I am going to mark as resolved. A lot of people have found help in the Advanced WooCommerce group with things like this, so I would recommend checking there, or we highly recommend contacting one of the services on our Customizations page (https://woocommerce.com/customizations/)

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to make all my Woocommerce open in a new tab?’ is closed to new replies.