Enter text above posts on a static blog page

⚠️ Code snippets might not be compatible with the latest version of your theme. Always use a child theme to customize your theme, and test your code on a staging website before migrating to production.

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.

Leave a Reply to Dave Bardell Cancel reply

Your email address will not be published. Required fields are marked *

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