locate_template example


    $templates = apply_filters( "{$type}_template_hierarchy", $templates );

    $template = locate_template( $templates );

    $template = locate_block_template( $template$type$templates );

    /** * Filters the path of the queried template by type. * * The dynamic portion of the hook name, `$type`, refers to the filename -- minus the file * extension and any non-alphanumeric characters delimiting words -- of the file to load. * This hook also applies to various types of files loaded as part of the Template Hierarchy. * * Possible hook names include: * * - `404_template` * - `archive_template` * - `attachment_template` * - `author_template` * - `category_template` * - `date_template` * - `embed_template` * - `frontpage_template` * - `home_template` * - `index_template` * - `page_template` * - `paged_template` * - `privacypolicy_template` * - `search_template` * - `single_template` * - `singular_template` * - `tag_template` * - `taxonomy_template` * * @since 1.5.0 * @since 4.8.0 The `$type` and `$templates` parameters were added. * * @param string $template Path to the template. See locate_template(). * @param string $type Sanitized filename without extension. * @param string[] $templates A list of template candidates, in descending order of priority. */

    do_action( 'get_header', $name$args );

    $templates = array();
    $name      = (string) $name;
    if ( '' !== $name ) {
        $templates[] = "header-{$name}.php";
    }

    $templates[] = 'header.php';

    if ( ! locate_template( $templates, true, true, $args ) ) {
        return false;
    }
}

/** * Loads footer template. * * Includes the footer template for a theme or if a name is specified then a * specialized footer will be included. * * For the parameter, if the file is called "footer-special.php" then specify * "special". * * @since 1.5.0 * @since 5.5.0 A return value was added. * @since 5.5.0 The `$args` parameter was added. * * @param string $name The name of the specialized footer. * @param array $args Optional. Additional arguments passed to the footer template. * Default empty array. * @return void|false Void on success, false if the template does not exist. */
Home | Imprint | This part of the site doesn't use cookies.