Skip to content

Instantly share code, notes, and snippets.

@neilgee
Created January 7, 2016 07:40
Show Gist options
  • Save neilgee/7761c34ddc935a9c8351 to your computer and use it in GitHub Desktop.
Save neilgee/7761c34ddc935a9c8351 to your computer and use it in GitHub Desktop.
genesis_do_posts_page_heading
<?php
///genesis/lib/structure/archive.php
add_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
/**
* Add custom headline and description to assigned posts page.
*
* If we're not on a posts page, then nothing extra is displayed.
*
* @since 2.2.1
*
* @uses genesis_a11y() Check if a post type should potentially support an archive setting page.
* @uses genesis_do_post_title() Get list of custom post types which need an archive settings page.
*
* @return null Return early if not on relevant posts page.
*/
function genesis_do_posts_page_heading() {
if ( ! genesis_a11y( 'headings' ) ) {
return;
}
$posts_page = get_option( 'page_for_posts' );
if ( is_null( $posts_page ) ) {
return;
}
if ( ! is_home() || genesis_is_root_page() ) {
return;
}
printf( '<div %s>', genesis_attr( 'posts-page-description' ) );
printf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), get_the_title( $posts_page ) );
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment