render_block_core_template_part_post
Action HookDescription
Fires when a block template part is loaded from a template post stored in the database.Hook Information
File Location |
wp-includes/blocks/template-part.php
View on GitHub
|
Hook Type | Action |
Line Number | 65 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$template_part_id
|
The requested template part namespaced to the theme. |
array
|
$attributes
|
The block attributes. |
WP_Post
|
$template_part_post
|
The template part post object. |
string
|
$content
|
The template part content. |
Usage Examples
Basic Usage
<?php
// Hook into render_block_core_template_part_post
add_action('render_block_core_template_part_post', 'my_custom_function', 10, 4);
function my_custom_function($template_part_id, $attributes, $template_part_post, $content) {
// Your custom code here
}
Source Code Context
wp-includes/blocks/template-part.php:65
- How this hook is used in WordPress core
<?php
60 * @param string $template_part_id The requested template part namespaced to the theme.
61 * @param array $attributes The block attributes.
62 * @param WP_Post $template_part_post The template part post object.
63 * @param string $content The template part content.
64 */
65 do_action( 'render_block_core_template_part_post', $template_part_id, $attributes, $template_part_post, $content );
66 } else {
67 $template_part_file_path = '';
68 // Else, if the template part was provided by the active theme,
69 // render the corresponding file content.
70 if ( 0 === validate_file( $attributes['slug'] ) ) {
PHP Documentation
<?php
/**
* Fires when a block template part is loaded from a template post stored in the database.
*
* @since 5.9.0
*
* @param string $template_part_id The requested template part namespaced to the theme.
* @param array $attributes The block attributes.
* @param WP_Post $template_part_post The template part post object.
* @param string $content The template part content.
*/
Quick Info
- Hook Type: Action
- Parameters: 4
- File: wp-includes/blocks/template-part.php
Related Hooks
Related hooks will be displayed here in future updates.