P
P
PM2018-06-04 03:35:16
WordPress
PM, 2018-06-04 03:35:16

How to open products in a new tab?

Hello!
It is necessary to open each product from the catalog page in a new tab, by default. Can you help?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Syomka Gavrilenko, 2018-06-04
@jimmykoks

To do this, just add to your theme's functions.php file:

/* Open Products in New Tab Woocommerce-DevelopingSense */
remove_action( 'woocommerce_before_shop_loop_item','woocommerce_template_loop_product_link_open', 10 );
// add a hook to my custom function
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">';
}

Source: https://www.developingsense.com/blog/open-woocomme...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question