I need to add target="_blank"
to links I'm retrieving using this PHP code on a WordPress+WooCommerce installation:
(我需要在WordPress + WooCommerce安装中使用此PHP代码的链接中添加target="_blank"
:)
$products = wc_get_products([
'status' => 'publish',
'limit' => -1,
'product_cat' => 'talleres'
]);
$locaciones = array_map(function ($product) {
return [
// more code goes here, I just deleted it for this question
'popup_html' => $product->get_categories() // this is where I need the target="_blank"
];
}, $products);
I tried with jQuery:
(我尝试使用jQuery:)
$(document).ready( function(){
$('a').attr('target', '_blank');
});
But it is not working, it doesn't add the target="_blank"
to the link.
(但是它不起作用,它没有将target="_blank"
到链接中。)
I'm thinking maybe this can be added directly to the PHP code?
(我在想,这可以直接添加到PHP代码中吗?)
ask by leandroprz translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…