Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@srikat
Created December 16, 2013 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srikat/7983414 to your computer and use it in GitHub Desktop.
Save srikat/7983414 to your computer and use it in GitHub Desktop.
Page Template in Genesis for showing a hard coded header image for a given Page or its child pages. For other Pages, if a featured image is present, then that will be used as the header image. http://sridharkatakam.com/custom-page-template-genesis-shows-featured-image-banner/#comment-1399. http://codex.wordpress.org/Conditional_Tags#Testing_for_…
<?php
/**
* This file adds the Banner template.
*
* @author Sridhar Katakam
* @package Generate
* @subpackage Customizations
*/
/*
Template Name: Banner Page
*/
// Remove header, navigation, breadcrumbs, footer widgets, footer
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
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 );
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
remove_action( 'genesis_before', 'genesis_do_subnav' );
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
remove_action( 'genesis_footer', 'genesis_footer_widget_areas' );
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
remove_action( 'genesis_footer', 'genesis_do_footer' );
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
add_action ( 'genesis_before_header', 'sk_add_banner_image' );
function sk_add_banner_image() {
global $post;
if ( is_page( 'about' ) || '2' == $post->post_parent ) {
// the page is "About", or the parent of the page is "About". where 2 is the ID of "About" Page.
echo '<div class="banner-image"><div class="wrap">';
echo '<img src="' . get_stylesheet_directory_uri() . '/images/about.jpg" />';
echo '</div></div>';
}
elseif ( has_post_thumbnail() ) {
echo '<div class="banner-image">
<div class="wrap">
<img src="' . genesis_get_image( array( 'format' => 'url' ) ) . '" />
</div>
</div>';
}
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment