• Resolved rphdigital

    (@rphdigital)


    Hi.

    I need that when a user accesses the page of any product, it always opens in a new tab, whatever the product is and where the product is located. How can I put all links to products with target = “_ blank” ?. Can anybody help me?

    Thank you

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @rphdigital!

    You can use the following code to achieve this:

    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 '<a target="_blank" href="' . get_the_permalink() . '" class="woocommerce-LoopProduct-link">';
    }

    You can add the code snippet to your site following the instructions here:

    https://rynaldo.com/how-to-add-custom-code-to-your-woocommerce-wordpress-site-the-right-way/

    Cheers!

    Cheers!

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy!

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Links to products in new tab’ is closed to new replies.