frontpage_template_hierarchy
Filter HookDescription
Gets the template hierarchy for the given template slug to be created. Note: Always add `index` as the last fallback template.Hook Information
File Location |
wp-includes/block-template-utils.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1575 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$slug
|
The template slug to be created. |
bool
|
$is_custom
|
Optional. Indicates if a template is custom or part of the template hierarchy. Default false. |
string
|
$template_prefix
|
Optional. The template prefix for the created template. Used to extract the main template type, e.g. in `taxonomy-books` the `taxonomy` is extracted. Default empty string. |
Usage Examples
Basic Usage
<?php
// Hook into frontpage_template_hierarchy
add_filter('frontpage_template_hierarchy', 'my_custom_filter', 10, 3);
function my_custom_filter($slug, $is_custom, $template_prefix) {
// Your custom filtering logic here
return $slug;
}
Source Code Context
wp-includes/block-template-utils.php:1575
- How this hook is used in WordPress core
<?php
1570 /** This filter is documented in wp-includes/template.php */
1571 return apply_filters( 'page_template_hierarchy', array( 'page', 'singular', 'index' ) );
1572 }
1573 if ( 'front-page' === $slug ) {
1574 /** This filter is documented in wp-includes/template.php */
1575 return apply_filters( 'frontpage_template_hierarchy', array( 'front-page', 'home', 'index' ) );
1576 }
1577
1578 $matches = array();
1579
1580 $template_hierarchy = array( $slug );
PHP Documentation
<?php
/**
* Gets the template hierarchy for the given template slug to be created.
*
* Note: Always add `index` as the last fallback template.
*
* @since 6.1.0
*
* @param string $slug The template slug to be created.
* @param bool $is_custom Optional. Indicates if a template is custom or
* part of the template hierarchy. Default false.
* @param string $template_prefix Optional. The template prefix for the created template.
* Used to extract the main template type, e.g.
* in `taxonomy-books` the `taxonomy` is extracted.
* Default empty string.
* @return string[] The template hierarchy.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/block-template-utils.php
Related Hooks
Related hooks will be displayed here in future updates.