Include introductory text on Genesis blog archive

When editing categories and tags, you can specify an optional “Archive Intro Text” to include at the top of the archive, below the archive page title.

When you specify a posts page in Settings > Reading, it uses the page title as the “Archive Intro Title”, but the “Archive Intro Text” is left empty. The code below changes the default behavior, displaying the page content as the intro text on the main blog archive.

<?php
/**
* Blog Archive Intro
* Use the post content of the blog page as the "intro text" on blog archive
*
* @author Bill Erickson
* @see https://www.billerickson.net/code/genesis-blog-archive-intro-text/
*/
function be_blog_archive_intro() {
// Copied genesis_do_posts_page_heading() from lib/structure/archive.php
if ( ! genesis_a11y( 'headings' ) ) {
return;
}
$posts_page = get_option( 'page_for_posts' );
if ( null === $posts_page ) {
return;
}
if ( ! is_home() || genesis_is_root_page() ) {
return;
}
/** This action is documented in lib/structure/archive.php */
do_action( 'genesis_archive_title_descriptions', get_the_title( $posts_page ), get_post( $posts_page )->post_content, 'posts-page-description' );
}
remove_action( 'genesis_before_loop', 'genesis_do_posts_page_heading' );
add_action( 'genesis_before_loop', 'be_blog_archive_intro' );
view raw functions.php hosted with ❤ by GitHub

Note: WordPress removes the content editor for the posts page if it’s empty. To get around this, use the following workflow:

  1. Create the posts page. Go to Pages > Add New, and create a page (ex: “Blog”).
  2. Type your introductory text in the content area.
  3. Go to Settings > Reading and select your new page to be posts page.

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk