Enter text above posts on a static blog page

If you’ve set up the Customizr theme so that you have you blog posts on a separate page, you might want to include some text or other content above the list of posts. Here’s how:

Let’s say that your separate blog page is called “Blog” and has the slug “blog”.

Add the following code to your functions.php:

 

// Add content of page called "blog" to the page that contains the list of blog posts
add_action  ( '__before_loop', 'add_blog_page_content_before_post_list');
function add_blog_page_content_before_post_list() {
	if ( is_home() ) {
		$post = get_page_by_path( '/blog' );
		echo wpautop($post->post_content);
	}
}

 

Where to copy/paste this code? => in your functions.php file. We strongly recommend you create a child theme. Download a start-up child theme here.

Remember: you shouldn’t edit the theme’s functions.php.

See How to customize the Customizr WordPress theme for more information on how to set up a functions.php file in a child theme.

8 thoughts on “Enter text above posts on a static blog page”

Comments are closed.