Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to add a section after .site-header
- This topic has 12 replies, 3 voices, and was last updated 9 years, 7 months ago by Genesis Developer.
-
AuthorPosts
-
August 6, 2014 at 8:27 am #117348lopwalMember
Hello...
I want to add a section after the .site-header section to a child theme.
By default, genesis loads like this:
.site-container ----> .site-header ---->.site-inner.but i want to add a div between .site-header and .site-inner.
something like this:
.site-container ----> .site-header ---->.custom-header ---->.site-inner.I am trying that with a new page template.
http://sitecarehub.hol.es/genesis
thanks in advance.August 6, 2014 at 9:01 am #117355Ben @ Inbound CreativeMemberOpen your functions.php file.
Anywhere underneath:
//* Child theme (do not remove) define( 'CHILD_THEME_NAME', __( 'xxx' ) ); define( 'CHILD_THEME_URL', 'xxx' ); define( 'CHILD_THEME_VERSION', 'xxx' );
Paste the following:
add_action( 'genesis_after_header', 'am_custom_header' ); function am_custom_header() { echo '<div id="custom-header-area" class="custom-header-area"><div class="wrap">'; genesis_widget_area( 'custom-header', array( 'before' => '<div class="custom-header"><div class="wrap">', 'after' => '</div></div>', ) ); echo '</div></div>'; } //* Register sidebar genesis_register_sidebar( array( 'id' => 'custom-header', 'name' => __( 'Custom Header', 'am'), 'description' => __( 'This is where you put any widgets you want to appear in your custom header', 'am' ), ) );
August 6, 2014 at 10:12 am #117363lopwalMemberMay I use that code in a page template?
August 6, 2014 at 10:15 am #117365Ben @ Inbound CreativeMemberDo you only want it to appear on the front page?
August 6, 2014 at 10:26 am #117368lopwalMemberYes...
August 6, 2014 at 4:06 pm #117447lopwalMemberYes, I need it only in a determinated page.
August 7, 2014 at 3:23 am #117537Ben @ Inbound CreativeMemberIf it's only the home page you want it to appear on, simply add:
add_action( 'genesis_after_header', 'am_custom_header' ); if ( is_home() || is_front_page() ) { function am_custom_header() { echo '<div id="custom-header-area" class="custom-header-area"><div class="wrap">'; genesis_widget_area( 'custom-header', array( 'before' => '<div class="custom-header"><div class="wrap">', 'after' => '</div></div>', ) ); echo '</div></div>'; } } //* Register sidebar genesis_register_sidebar( array( 'id' => 'custom-header', 'name' => __( 'Custom Header', 'am'), 'description' => __( 'This is where you put any widgets you want to appear in your custom header', 'am' ), ) );
Otherwise, the approach is slightly more complicated. Let me know.
Thanks,
Ben
August 7, 2014 at 7:12 am #117555lopwalMemberThat should be added to a page template, right?
Thank you in advance.
August 7, 2014 at 7:18 am #117556Ben @ Inbound CreativeMemberSorry, no. If you use the last code – and only want it to work on the home page – you'd put it into your functions.php file.
August 7, 2014 at 7:21 am #117557lopwalMemberBut I want that in a page template... because I want to personalize many pages...
August 7, 2014 at 7:25 am #117558Ben @ Inbound CreativeMemberAh, sorry. I misunderstood what you meant.
If you want to use it like you have said, then use, you'd insert the below code into a page template.
add_action( 'genesis_after_header', 'am_custom_header' ); function am_custom_header() { echo '<div id="custom-header-area" class="custom-header-area"><div class="wrap">'; genesis_widget_area( 'custom-header', array( 'before' => '<div class="custom-header"><div class="wrap">', 'after' => '</div></div>', ) ); echo '</div></div>'; }
You'd then add the following to your functions.php file.
//* Register sidebar genesis_register_sidebar( array( 'id' => 'custom-header', 'name' => __( 'Custom Header', 'am'), 'description' => __( 'This is where you put any widgets you want to appear in your custom header', 'am' ), ) );
August 8, 2014 at 5:11 pm #117829lopwalMemberNot working yet...
August 8, 2014 at 9:40 pm #117861Genesis DeveloperMemberBut I want that in a page template… because I want to personalize many pages…
Then you will use is_page() conditional tag. See the Codex for better knowledge.
add_action( 'genesis_after_header', 'am_custom_header' ); function am_custom_header() { if( is_page( 42 ) ){ // When Page 42 (ID) is being displayed. echo '<div id="custom-header-area" class="custom-header-area"><div class="wrap">'; genesis_widget_area( 'custom-header', array( 'before' => '<div class="custom-header"><div class="wrap">', 'after' => '</div></div>', ) ); echo '</div></div>'; } }
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.