admin管理员组文章数量:1122846
I have created a page that is set as my "Posts Page" in the "Reading" settings. On that page I have added a Gutenberg block but it doesn't show up on the page so long as I have the page set as the "Posts Page." Is there any way for me to have that Gutenberg block show up above the post list using the index.php
template instead of creating a custom page template with a post loop to use as my blog page?
I have created a page that is set as my "Posts Page" in the "Reading" settings. On that page I have added a Gutenberg block but it doesn't show up on the page so long as I have the page set as the "Posts Page." Is there any way for me to have that Gutenberg block show up above the post list using the index.php
template instead of creating a custom page template with a post loop to use as my blog page?
1 Answer
Reset to default 2 +50You could add something like this before the while()
-loop in your index.php
:
// only if we are on the posts page
if ( is_home() ) {
// global post record
global $post;
// get the posts-page record
$post = get_post( get_option( 'page_for_posts' ) );
// set it up as the global $post
setup_postdata( $post );
// content output, cheaply wrapped
echo '<div class="posts-page-content">';
the_title();
the_content();
echo '</div>';
// restore the post data to the original one
wp_reset_postdata();
}
Then you propably have to add some lines of CSS to look it nice and clean.
本文标签: theme developmentDisplay Gutenberg blocks from quotPosts Pagequot above the post list
版权声明:本文标题:theme development - Display Gutenberg blocks from "Posts Page" above the post list? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736293920a1929245.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论