Adding target “_blank” on Button Extra Navigation in Astra Theme

Adding Button as Last Menu Item at Header

You can easily add the custom action button at right side of the header menu items via Astra Customizer.

  1. Go to Astra theme customier
  2. Click on the Header -> Primary Menu section
  3. Select “Button” from Last Item in Menu drop down
  4. Complete the settings as per your requirements.

I did this with small JavaScript code. You will install or create the astra child theme. So your all custom code will not remove when you will update the Astra theme.

I just add this code into the functions.php file of my astra child theme.

add_action( 'wp_footer', 'paulc_add_target_blank_ast_button' );
function paulc_add_target_blank_ast_button() {
echo '<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".ast-custom-button-link").attr("target", "_blank");
});
</script>'."\n";
}

After adding this code I am getting this new HTML markup for my header button.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.