_block_template_render_without_post_block_context()
Removes post details from block context when rendering a block template.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
Array
. Filtered context.
Usage
_block_template_render_without_post_block_context( $context );
- $context(array) (required)
- Default context.
Changelog
Since 5.8.0 | Introduced. |
_block_template_render_without_post_block_context() block template render without post block context code WP 6.7.1
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; }