Last active
December 9, 2023 23:28
-
-
Save danielcharrua/d3a41b41ead2a103046e51b7fd78d43c to your computer and use it in GitHub Desktop.
Add Gutenberg content to blog page on Astra
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Please add this to your functions.php | |
/** | |
* This snippet adds Blog page Gutenberg content before the posts grid on Astra theme if you are using a static homepage. | |
* | |
* First create a page for displaying posts, for example "Blog", add any Gutenberg block. | |
* Then on settings assign a static frontpage and the created "Blog" page to blog posts. | |
* | |
* You can now add any block content to the "Blog" page and it will be shown before the posts loop. | |
*/ | |
if ( ! function_exists( 'astra_blog_page_title_and_content' ) ) { | |
function astra_blog_page_title_and_content() { | |
if ( is_home() ) { ?> | |
<section class="ast-archive-description"> | |
<?php | |
$page_for_posts_id = get_option('page_for_posts'); | |
echo get_post_field( 'post_content', $page_for_posts_id ); | |
?> | |
</section> | |
<?php } | |
} | |
add_action( 'astra_primary_content_top', 'astra_blog_page_title_and_content' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment