Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Override Header Layout in Avada Child Theme
<?php
/* Override (modify) the Avada header layouts in a child theme by establishing a local version. */
/* Avada has 6 header layouts selectable via Avada > Theme Options > Header > Header Content. These map to files at
"/wp-content/themes/Avada/templates". You can use your browser's devtools to look in the header for something like
'<div class="fusion-header-v1 ... ">' which will help identify what's being used, if you don't already know.
*/
// Copy this block from "/wp-content/themes/Avada/templates/header.php". If you are not using header_1 then copy the appropriate block.
if ( ! function_exists( 'avada_header_1' ) ) {
function avada_header_1() {
if ( ! in_array( Avada()->settings->get( 'header_layout' ), array( 'v1', 'v2', 'v3' ) ) ) {
return;
}
get_template_part( 'templates/header-1' );
}
}
add_action( 'avada_header', 'avada_header_1', 20 );
// Don't change anything in the code, just add the block to your child-theme's 'functions.php'.
// Copy the appropriate file from "/wp-content/themes/Avada/templates", in this case 'header-1.php', to the same folder in the child theme, like "/wp-content/themes/Avada-Child-Theme/templates/header-1.php.
?>
<div class="fusion-header">
<div class="fusion-row">
<?php avada_logo(); ?>
<?php avada_main_menu(); ?>
</div>
</div>
<?php
// Make your changes to the copy of header-1.php in the child-theme folder. That copy will be called during the "avada_header" action.
?>
<div class="fusion-header">
<div class="fusion-row">
<!-- New thing. -->
<button class="reservations"><a href="tel:1-123-456-7890">Call for Reservations</a></button>
<?php avada_logo(); ?>
<?php avada_main_menu(); ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment