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.

/**
 * Blog Archive Intro
 * Use the post content of the blog page as the "intro text" on blog archive 
 * 
 * @author Bill Erickson
 * @link 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' );

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 the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

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

Let's Talk