wp_before_load_template
Action HookDescription
Fires before a template file is loaded.Hook Information
File Location |
wp-includes/template.php
View on GitHub
|
Hook Type | Action |
Line Number | 807 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$_template_file
|
The full path to the template file. |
bool
|
$load_once
|
Whether to require_once or require. |
array
|
$args
|
Additional arguments passed to the template. |
Usage Examples
Basic Usage
<?php
// Hook into wp_before_load_template
add_action('wp_before_load_template', 'my_custom_function', 10, 3);
function my_custom_function($_template_file, $load_once, $args) {
// Your custom code here
}
Source Code Context
wp-includes/template.php:807
- How this hook is used in WordPress core
<?php
802 *
803 * @param string $_template_file The full path to the template file.
804 * @param bool $load_once Whether to require_once or require.
805 * @param array $args Additional arguments passed to the template.
806 */
807 do_action( 'wp_before_load_template', $_template_file, $load_once, $args );
808
809 if ( $load_once ) {
810 require_once $_template_file;
811 } else {
812 require $_template_file;
PHP Documentation
<?php
/**
* Fires before a template file is loaded.
*
* @since 6.1.0
*
* @param string $_template_file The full path to the template file.
* @param bool $load_once Whether to require_once or require.
* @param array $args Additional arguments passed to the template.
*/
Quick Info
- Hook Type: Action
- Parameters: 3
- File: wp-includes/template.php
Related Hooks
Related hooks will be displayed here in future updates.