Last active
August 8, 2016 14:36
-
-
Save waynebcox/25fb8939fa0c699532c825a7ce283a68 to your computer and use it in GitHub Desktop.
Add full width entry-header-wrapper to Genesis child theme; includes adding to blog and archive pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// * Relocate titles on Page, Post and other single pages | |
add_action( 'genesis_after_header','relocate_entry_title_singular' ); | |
function relocate_entry_title_singular() { | |
if ( ! is_singular() ) | |
return; | |
echo '<div class="entry-header-wrapper"><div class="wrap">'; | |
genesis_do_post_title(); | |
genesis_post_info(); | |
echo '</div></div>'; | |
if ( is_page_template( 'page_blog.php' ) ) | |
return; | |
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); | |
remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); | |
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); | |
if ( ! is_singular('post' ) ) | |
return; | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
} | |
//* Relocate titles on Category Archive pages | |
add_action( 'genesis_after_header','relocate_entry_title_category_pages' ); | |
function relocate_entry_title_category_pages() { | |
global $wp_query; | |
if ( ! is_category() && ! is_tag() && ! is_tax() ) | |
return; | |
if ( get_query_var( 'paged' ) >= 2 ) | |
return; | |
$term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : $wp_query->get_queried_object(); | |
if ( ! $term || ! isset( $term->meta ) ) | |
return; | |
$headline = $intro_text = ''; | |
if ( ! $term->meta['headline'] && ! $term->meta['intro_text'] ) | |
return; | |
echo '<div class="entry-header-wrapper"><div class="wrap">'; | |
if ( $term->meta['headline'] ) | |
$headline = sprintf( '<h1 class="archive-title">%s</h1>', strip_tags( $term->meta['headline'] ) ); | |
if ( $term->meta['intro_text'] ) | |
$intro_text = apply_filters( 'genesis_term_intro_text_output', $term->meta['intro_text'] ); | |
if ( $headline || $intro_text ) | |
printf( '<div class="archive-description taxonomy-description">%s</div>', $headline . $intro_text ); | |
echo '</div></div>'; | |
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); | |
} | |
//* Relocate titles on Author Archive pages | |
add_action( 'genesis_after_header','relocate_entry_title_author_archive_pages' ); | |
function relocate_entry_title_author_archive_pages() { | |
if ( ! is_author() ) | |
return; | |
if ( get_query_var( 'paged' ) >= 2 ) | |
return; | |
$headline = get_the_author_meta( 'headline', (int) get_query_var( 'author' ) ); | |
$intro_text = get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) ); | |
if ( ! $headline && ! $intro_text ) | |
return; | |
$headline = $headline ? sprintf( '<h1 class="archive-title">%s</h1>', strip_tags( $headline ) ) : ''; | |
$intro_text = $intro_text ? apply_filters( 'genesis_author_intro_text_output', $intro_text ) : ''; | |
echo '<div class="entry-header-wrapper"><div class="wrap">'; | |
printf( '<div class="archive-description author-description">%s</div>', $headline . $intro_text ); | |
echo '</div></div>'; | |
remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 ); | |
} | |
//* Relocate titles on CPT Archive pages | |
add_action( 'genesis_after_header','relocate_entry_title_cpt_archive_pages' ); | |
function relocate_entry_title_cpt_archive_pages() { | |
if ( ! is_post_type_archive() || ! genesis_has_post_type_archive_support() ) | |
return; | |
if ( get_query_var( 'paged' ) >= 2 ) | |
return; | |
$headline = genesis_get_cpt_option( 'headline' ); | |
$intro_text = genesis_get_cpt_option( 'intro_text' ); | |
if ( ! $headline && ! $intro_text ) | |
return; | |
$headline = $headline ? sprintf( '<h1 class="archive-title">%s</h1>', $headline ) : ''; | |
$intro_text = $intro_text ? apply_filters( 'genesis_cpt_archive_intro_text_output', $intro_text ) : ''; | |
echo '<div class="entry-header-wrapper"><div class="wrap">'; | |
printf( '<div class="archive-description cpt-archive-description">%s</div>', $headline . $intro_text ); | |
echo '</div></div>'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.entry-header-wrapper { | |
margin-top: 112px; /* Themes like Digital Pro require this top margin */ | |
text-align: center; | |
min-height: 360px; | |
} | |
.entry-header-wrapper .wrap { | |
max-width: 1280px; | |
float: none; | |
margin: 0 auto; | |
} | |
/* Page specific images for background */ | |
.about-page .entry-header-wrapper { | |
background: url("/wp-content/uploads/2016/08/About.jpg"); | |
background-size: cover !important; | |
background-position: center top !important; | |
background-repeat: no-repeat !important; | |
} | |
.page .entry-title, | |
.single .entry-title { | |
color: #fff; | |
text-align: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment