Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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.

    #1180876

    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

    #1180979

    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?

    #1180982

    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

    #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?

    #1181072

    wrong post – sorry

    • This reply was modified 4 years, 5 months ago by Guenni007.
    #1181080

    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’);

    #1181104

    Hi,

    Glad you figured it out and thanks for sharing your solution :)

    Let us know if you have any other questions or issues!

    Best regards,
    Yigit

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Set external product link to open in new tab?’ is closed to new replies.