Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Forked from robincornett/functions.php
Last active August 29, 2015 14:19
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 GaryJones/67d89afb16dc1cbf852e to your computer and use it in GitHub Desktop.
Save GaryJones/67d89afb16dc1cbf852e to your computer and use it in GitHub Desktop.
<?php
/**
* Blog Intro
*/
add_action( 'genesis_before_loop', 'rgc_blog_intro' );
/**
* Add title and content before blog archive loop.
*
* @author Robin Cornett
* @link https://gist.github.com/robincornett/cca2a45f273b35399bd2
*
* @return null Return early if not using a page for posts.
*/
function rgc_blog_intro() {
$page_for_posts = get_post( get_option( 'page_for_posts' ) );
if ( is_null( $page_for_posts ) ) {
return;
}
$title = $page_for_posts->post_title;
$content = $page_for_posts->post_content;
if ( $title && ! class_exists( 'Display_Featured_Image_Genesis' ) ) {
echo '<h1 class="archive-title">' . $title . '</h1>';
}
if ( $content ) {
echo '<div class="archive-description">' . wpautop( $content ) . '</div>';
}
}
genesis();
@robincornett
Copy link

Is is_null the correct check? a var_dump returns 0, not NULL, if the front page is set to Latest Posts. Doing a if ( ! $posts_page ) is working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment