-
AuthorPosts
-
February 3, 2020 at 1:45 am #1180729
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.February 3, 2020 at 12:38 pm #1180876Hey 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,
VictoriaFebruary 3, 2020 at 4:33 pm #1180979Thanks, 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?
February 3, 2020 at 4:37 pm #1180982Hey,
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,
YigitFebruary 3, 2020 at 10:11 pm #1181065“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?February 3, 2020 at 10:37 pm #1181072wrong post – sorry
-
This reply was modified 5 years, 9 months ago by
Guenni007.
February 3, 2020 at 11:14 pm #1181080Never 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’);February 4, 2020 at 12:16 am #1181104 -
This reply was modified 5 years, 9 months ago by
-
AuthorPosts
- The topic ‘Set external product link to open in new tab?’ is closed to new replies.
