Skip to content

Instantly share code, notes, and snippets.

@PurpleHippoDesign
Created September 3, 2018 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PurpleHippoDesign/6821ff4481ba5db6e3ceee49419d086e to your computer and use it in GitHub Desktop.
Save PurpleHippoDesign/6821ff4481ba5db6e3ceee49419d086e to your computer and use it in GitHub Desktop.
Moves titles for pages, posts, page for posts, archives, custom post type archives, category, tag and author archives into the header and wraps in markup
<?php
//* Add opening markup for the Page Header
add_action( 'genesis_before_header', 'wwd_opening_page_header' );
function wwd_opening_page_header() {
if (is_front_page() || is_search() || is_404() ) {
return;
}
else {
?>
<div class="header-wrap bg-primary">
<?php
}
}
//* Add closing markup for the Page Header
add_action( 'genesis_after_header', 'wwd_closing_page_header' );
function wwd_closing_page_header() {
if (is_front_page() || is_search() || is_404() ) {
return;
}
else if (( ( is_page() && !is_page_template( 'page_landing.php' ) ) || is_single() || is_archive() || is_home() )) {
?>
<div class="page-header">
<div class="wrap">
<?php
if ( is_archive() || is_post_type_archive() ) {
remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' );
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
echo '<h1>' . get_the_archive_title() . '</h1>';
}
elseif( is_home() && get_option('page_for_posts') ) {
$posts_page_id = get_option('page_for_posts');
echo '<h1>' . get_the_title($posts_page_id) . '</h1>';
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
} else {
if ( is_singular() ) {
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}
echo the_title( '<h1>', '</h1>', false );
}
?>
</div>
</div>
</div>
<?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment