• Resolved kteschmitt

    (@kteschmitt)


    Hi,

    I’d like to use the call to action widget to link to another site in a new tab. Is there a way to do this without creating a child theme? Can I use the Custom CSS form to add in a line of js to append a target="_blank" to the button?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there kteschmitt,

    How are you doing today?

    You can definitely use jQuery to add target blank to the call to action widget link.

    If you don’t want to create child theme or edit theme core files you can do this with plugins such as this one: https://wordpress.org/plugins/code-snippets/. I tested it with the below code and everything worked just fine.

    Please add the following code there:

    function custom_js(){ ?>
    <script type="text/javascript">
    	jQuery( window ).load(function(){
    		jQuery( 'a.call-to-action-button').attr('target', '_blank');
    	});
    </script>
    <?php }
    add_action('wp_footer', "custom_js");

    This should open your call to action widget link in a new page.

    Hope this helps 🙂

    Cheers,
    Bojan

    Thread Starter kteschmitt

    (@kteschmitt)

    Thanks Bojan! That was so quick and easy and it works perfectly. I really appreciate the speedy response as well. Have a great day!

    Glad I could help 🙂

    Have a great day too!

    Cheers,
    Bojan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Call to Action Widget: open link in new tab?’ is closed to new replies.