Hi,
How does one set the external product link on the Shop page to open in a new tab? Class is button product_type_external. Thanks.
Hey GWS,
Here is the code you can put in your funtions.php
function addCustomScript(){
?>
<script>
function a() {
jQuery('.products.columns-4 .button.product_type_external').attr('target', '_blank');
}
$(window).load(function() {
a();
});
</script>
<?php
}
add_action('wp_footer', 'addCustomScript');
If you need further assistance please let us know.
Best regards,
Victoria
Thanks, but we tried that already and it didn’t work. Note that we are using CloudFlare and we did clear the cache. Still doesn’t work on retry. Any thoughts?
Hey,
Could you please go to Enfold theme options > Performance and check if “Load jQuery in your footer” is enabled? If enabled, please try disabling it and check if that helps.
We have made improvements on “Load jQuery in your footer” button which will be available in upcoming version so if disabling helps, you can enable it once again after updating the theme :)
Regards,
Yigit
“Load jQuery in the footer” is already disabled. We are seeing an error in the console “Uncaught TypeError: $ is not a function
at (index):399” File is …/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 Does that provide any clues as to why the functions.php code isn’t working with the shop external link opening in a new tab?
wrong post – sorry
Never mind… I corrected the script and got it working. See below
function addCustomScript(){
?>
<script>
function a() {
jQuery(‘.products.columns-4 .button.product_type_external’).attr(‘target’, ‘_blank’);
}
jQuery(window).load(function() {
a();
});
</script>
<?php
}
add_action(‘wp_footer’, ‘addCustomScript’);