Extended Menu1 CTA Button

Hi, how can I make the CTA Button link on the Extended Menu1 Header open in a new window?

Hello, can you please provide a link to your website in order to let me check its header?

You can use some link shortener if you don’t want to leave the link to your site in this topic.

Kind Regards, Roman.
aThemes Support

On this site: https://rb.gy/f6iaim

Hello, thank you for the link. You can try to do this with jQuery.

  1. Install and activate Insert Headers and Footers plugin that will allow you to insert JavaScript (jQuery) code.

  2. Go to Settings → Insert Headers and Footers section, add the following code to Scripts in Header field, and click Save button.

<script>
    jQuery(document).ready(function(){
        jQuery('.top-bar .header-cta .button').attr('target', '_blank');
    });
</script>

Please feel free to ask any other questions that you might have.

Kind Regards, Roman.
aThemes Support

Thanks! Are there any solutions that don’t involve adding a header script (slowing down loading)?

Hello,

Are there any solutions that don’t involve adding a header script (slowing down loading)?

You can replace this code in template-parts/menus/menu-menuStyle6.php file (line 63):

<a href="<?php echo esc_url( $button_url ); ?>" class="btn">

…with this:

<a href="<?php echo esc_url( $button_url ); ?>" class="btn" target="_blank">

However, please note that you’ll have to repeat this modification after each theme update.

Kind Regards, Roman.
aThemes Support

Doesn’t seem to be working for me.
https://rb.gy/f6iaim

Hello,

Doesn’t seem to be working for me.

It looks like you have switched from menu style 6 to menu style 3, so try to replace this code in template-parts/menus/menu-menuStyle3.php file (line 31):

<a class="button" href="<?php echo esc_url( $options['cta_url'] ); ?>"><?php echo esc_html( $options['cta_text'] ); ?></a>

…with this:

<a class="button" href="<?php echo esc_url( $options['cta_url'] ); target="_blank" ?>"><?php echo esc_html( $options['cta_text'] ); ?></a>

Kind Regards, Roman.
aThemes Support

That actually created an error for me.

I had to do this instead:

<a target="_blank" class="button" href="<?php echo esc_url( $options['cta_url'] ); ?>"><?php echo esc_html( $options['cta_text'] ); ?></a>

Yeah, sorry for that, my code had to be like this:

<a class="button" href="<?php echo esc_url( $options['cta_url'] ); ?>" target="_blank"><?php echo esc_html( $options['cta_text'] ); ?></a>

Kind Regards, Roman.
aThemes Support