Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @heatherpeters,

    I hope you are well today and thank you for your question.

    Have you tried using the target=”_blank” attribute of the anchor tag as described on the following pages?

    https://www.w3schools.com/tags/att_a_target.asp
    https://css-tricks.com/use-target_blank/

    Best Regards,
    Vinod Dalvi

    Hey there heatherpeters,

    Hope you’re well today!

    This is not possible out of a box with the current version of the plugin. Since this is an interesting idea I’ve added this as a featured request for the plugin so it will be considered for the future versions of the plugin.

    Until then you should be able to achieve that with some custom code. Please try adding the following code to your child theme functions.php:

    add_action('wp_footer','open_link_new_window');
    function open_link_new_window(){
    ?>
    <script>
    jQuery(function() {
       function handle_cta( ev ) {
           var href = jQuery( this ).attr( 'href' );
           window.open( href, '_blank' );
           return false;
       }
       jQuery(document).on('click', '.wdpu-cta', handle_cta);
    });
    </script>
    <?php
    }

    This should open the call to action button link in a new window.

    Please let me know if this helps ??

    Best regards,
    Bojan

    Thread Starter heatherpeters

    (@heatherpeters)

    Thank you both for the reply!!

    Vinod – I assumed that the Button Link in the Call to Action section only allowed for a URL, as the theme specifies in the grayed out writing? I didn’t think it would support HTML…Is this incorrect?

    Bojan – when I copy functions.php to my child theme in my hosting files, it renders my website completely inaccessible. I had this happen once with another plugin author that stated I could insert custom coding there, but it wasn’t possible to copy the functions file over in order to have it in the child theme, as the site couldn’t operate with two functions files present together. So, would I have to paste this code into the original functions.php file and just re-upload/overwrite?

    Hey there heatherpeters,

    Adding this to your theme functions.php would work but it is not a good idea since the changes will be lost once you update the theme.

    If you’re having issues setting this up in your child theme you could try using plugins such as this one which allows you to add custom scripts.

    When the plugin is activated add the following script to Header Footer >> Insert JS in Footer, see screenshot https://screencast.com/t/uBLOfeDf. Add the following there:

    jQuery(function() {
       function handle_cta( ev ) {
           var href = jQuery( this ).attr( 'href' );
           window.open( href, '_blank' );
           return false;
       }
       jQuery(document).on('click', '.wdpu-cta', handle_cta);
    });

    The result should be the same, please let me know if this helps ??

    Cheers,
    Bojan

    Thread Starter heatherpeters

    (@heatherpeters)

    This worked beautifully!!!!!!! Thank you!!!!

    Glad I could help ??

    Cheers,
    Bojan

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to open call to action URL in new window?’ is closed to new replies.