Community Forums › Forums › Archived Forums › General Discussion › Custom page templates and Headers
Tagged: Custom header, page template
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by
Jeffreydotfong.
-
AuthorPosts
-
February 14, 2016 at 9:44 pm #179052
Jeffreydotfong
MemberHi there,
I am new to genesis but have played with wordpress twentytwelve before.
I am trying to create a new page template and use a customised header-Landing.php specifically for my landing page. This is easy in twenty twelve because get_header is already in the page template. You just call the header.php file you want...
In genesis, I have managed to remove the header and call a new header-landing.php, but I cannot seem to hook in 'get_header' at the right place. The customised header is being pulled outside the "site-container", as if the new header is being called - then gensis() function runs after it.
How can effectively hook my customised header.php file into the genesis_header location hook?
my page template code:
<?php /* Template Name: Landing page template */ //Removing the header http://wpsites.net/web-design/remove-header/ remove_action( 'genesis_header', 'genesis_header_markup_open', 5 ); remove_action( 'genesis_header', 'genesis_do_header' ); remove_action( 'genesis_header', 'genesis_header_markup_close', 15 ); //getting the custom header file add_action('genesis_header', get_header('Landing')); genesis(); ?>February 15, 2016 at 3:18 am #179058Brad Dalton
ParticipantYou can use get_template_part in a custom function or echo the image in directly from your template using a custom function with the genesis_header hook.
Or
print the image using a custom function with hook and condtional tag from your functions file.
February 15, 2016 at 3:31 am #179059Jeffreydotfong
MemberThanks Brad,
I tried to use get_template_part ('Header','Landing') but just got the same result: the header ends up outside the site-container created by the genesis() function. It seems my actions aren't actually hooking into the right place:
add_action('genesis_header', get_template_part('Header','Landing'));By creating a custom function, do you mean re-creating the genesis() function? Or just using echo to pull in a particular header image - I was hoping I could use the same header for different page templates or the different headers for the same template...
February 15, 2016 at 3:40 am #179060Jeffreydotfong
MemberAh actually, calling it in a custom function worked.
add_action('genesis_header', 'loadlandingheader'); function loadlandingheader() { get_template_part('Header','Landing'); }How come I had to call it in a custom function to get it to sit inside the genesis() site-container?
February 15, 2016 at 6:10 am #179064Brad Dalton
ParticipantFebruary 15, 2016 at 6:12 am #179065Jeffreydotfong
MemberHaha, great. I won't be adding anymore actions without a new function then!
-
AuthorPosts
- The topic ‘Custom page templates and Headers’ is closed to new replies.