Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active May 10, 2020 20:47
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save srikat/8801138 to your computer and use it in GitHub Desktop.
Relocating Entry Title below Header in Genesis. http://sridharkatakam.com/relocating-entry-title-header-genesis/
// * 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>';
}
/* Relocating Entry Title below Header
--------------------------------------------- */
.entry-header-wrapper {
margin-top: 70px;
padding: 42px 0;
background-color: #F04848;
text-align: center;
}
.entry-header-wrapper .entry-title {
margin-bottom: 0;
}
.page .entry-header-wrapper + .site-inner, .single .entry-header-wrapper + .site-inner,
.archive .entry-header-wrapper + .site-inner {
margin-top: 80px;
}
.entry-header-wrapper .archive-description {
margin-bottom: 0;
}
.entry-header-wrapper, .entry-header-wrapper h1 {
color: #fff;
}
.entry-header-wrapper a {
color: #000;
}
@media only screen and (max-width: 1023px) {
.entry-header-wrapper {
margin-top: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment