
如何修复XAMPP环境“Apache意外关闭”错误
_block_template_render_without_post_block_context ( $context )
_block_template_render_without_post_block_context: 这个函数用于在没有post block的情况下渲染一个block模板。它用于在块编辑器中渲染块模板的预览。
在渲染区块模板时,从区块上下文中删除文章细节。
function _block_template_render_without_post_block_context( $context ) { /* * When loading a template directly and not through a page that resolves it, * the top-level post ID and type context get set to that of the template. * Templates are just the structure of a site, and they should not be available * as post context because blocks like Post Content would recurse infinitely. */ if ( isset( $context['postType'] ) && 'wp_template' === $context['postType'] ) { unset( $context['postId'] ); unset( $context['postType'] ); } return $context; }