[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> template.php (summary)

Template loading functions.

File Size: 825 lines (24 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 22 functions

  get_query_template()
  get_index_template()
  get_404_template()
  get_archive_template()
  get_post_type_archive_template()
  get_author_template()
  get_category_template()
  get_tag_template()
  get_taxonomy_template()
  get_date_template()
  get_home_template()
  get_front_page_template()
  get_privacy_policy_template()
  get_page_template()
  get_search_template()
  get_single_template()
  get_embed_template()
  get_singular_template()
  get_attachment_template()
  wp_set_template_globals()
  locate_template()
  load_template()

Functions
Functions that are not part of a class:

get_query_template( $type, $templates = array()   X-Ref
Retrieves path to a template.

Used to quickly retrieve the path of a template without including the file
extension. It will also check the parent theme, if the file exists, with
the use of locate_template(). Allows for more generic template location
without the use of the other get_*_template() functions.

param: string   $type      Filename without extension.
param: string[] $templates An optional list of template candidates.
return: string Full path to template file.

get_index_template()   X-Ref
Retrieves path of index template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'index'.

return: string Full path to index template file.

get_404_template()   X-Ref
Retrieves path of 404 template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is '404'.

return: string Full path to 404 template file.

get_archive_template()   X-Ref
Retrieves path of archive template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'archive'.

return: string Full path to archive template file.

get_post_type_archive_template()   X-Ref
Retrieves path of post type archive template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'archive'.

return: string Full path to archive template file.

get_author_template()   X-Ref
Retrieves path of author template in current or parent template.

The hierarchy for this template looks like:

1. author-{nicename}.php
2. author-{id}.php
3. author.php

An example of this is:

1. author-john.php
2. author-1.php
3. author.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'author'.

return: string Full path to author template file.

get_category_template()   X-Ref
Retrieves path of category template in current or parent template.

The hierarchy for this template looks like:

1. category-{slug}.php
2. category-{id}.php
3. category.php

An example of this is:

1. category-news.php
2. category-2.php
3. category.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'category'.

return: string Full path to category template file.

get_tag_template()   X-Ref
Retrieves path of tag template in current or parent template.

The hierarchy for this template looks like:

1. tag-{slug}.php
2. tag-{id}.php
3. tag.php

An example of this is:

1. tag-wordpress.php
2. tag-3.php
3. tag.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'tag'.

return: string Full path to tag template file.

get_taxonomy_template()   X-Ref
Retrieves path of custom taxonomy term template in current or parent template.

The hierarchy for this template looks like:

1. taxonomy-{taxonomy_slug}-{term_slug}.php
2. taxonomy-{taxonomy_slug}.php
3. taxonomy.php

An example of this is:

1. taxonomy-location-texas.php
2. taxonomy-location.php
3. taxonomy.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'taxonomy'.

return: string Full path to custom taxonomy term template file.

get_date_template()   X-Ref
Retrieves path of date template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'date'.

return: string Full path to date template file.

get_home_template()   X-Ref
Retrieves path of home template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'home'.

return: string Full path to home template file.

get_front_page_template()   X-Ref
Retrieves path of front page template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'frontpage'.

return: string Full path to front page template file.

get_privacy_policy_template()   X-Ref
Retrieves path of Privacy Policy page template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'privacypolicy'.

return: string Full path to privacy policy template file.

get_page_template()   X-Ref
Retrieves path of page template in current or parent template.

Note: For block themes, use locate_block_template() function instead.

The hierarchy for this template looks like:

1. {Page Template}.php
2. page-{page_name}.php
3. page-{id}.php
4. page.php

An example of this is:

1. page-templates/full-width.php
2. page-about.php
3. page-4.php
4. page.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'page'.

return: string Full path to page template file.

get_search_template()   X-Ref
Retrieves path of search template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'search'.

return: string Full path to search template file.

get_single_template()   X-Ref
Retrieves path of single template in current or parent template. Applies to single Posts,
single Attachments, and single custom post types.

The hierarchy for this template looks like:

1. {Post Type Template}.php
2. single-{post_type}-{post_name}.php
3. single-{post_type}.php
4. single.php

An example of this is:

1. templates/full-width.php
2. single-post-hello-world.php
3. single-post.php
4. single.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'single'.

return: string Full path to single template file.

get_embed_template()   X-Ref
Retrieves an embed template path in the current or parent template.

The hierarchy for this template looks like:

1. embed-{post_type}-{post_format}.php
2. embed-{post_type}.php
3. embed.php

An example of this is:

1. embed-post-audio.php
2. embed-post.php
3. embed.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'embed'.

return: string Full path to embed template file.

get_singular_template()   X-Ref
Retrieves the path of the singular template in current or parent template.

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'singular'.

return: string Full path to singular template file

get_attachment_template()   X-Ref
Retrieves path of attachment template in current or parent template.

The hierarchy for this template looks like:

1. {mime_type}-{sub_type}.php
2. {sub_type}.php
3. {mime_type}.php
4. attachment.php

An example of this is:

1. image-jpeg.php
2. jpeg.php
3. image.php
4. attachment.php

The template hierarchy and template path are filterable via the {@see '$type_template_hierarchy'}
and {@see '$type_template'} dynamic hooks, where `$type` is 'attachment'.

return: string Full path to attachment template file.

wp_set_template_globals()   X-Ref
Set up the globals used for template loading.


locate_template( $template_names, $load = false, $load_once = true, $args = array()   X-Ref
Retrieves the name of the highest priority template file that exists.

Searches in the stylesheet directory before the template directory and
wp-includes/theme-compat so that themes which inherit from a parent theme
can just overload one file.

param: string|array $template_names Template file(s) to search for, in order.
param: bool         $load           If true the template file will be loaded if it is found.
param: bool         $load_once      Whether to require_once or require. Has no effect if `$load` is false.
param: array        $args           Optional. Additional arguments passed to the template.
return: string The template filename if one is located.

load_template( $_template_file, $load_once = true, $args = array()   X-Ref
Requires the template file with WordPress environment.

The globals are set up for the template file to ensure that the WordPress
environment is available from within the function. The query variables are
also available.

param: string $_template_file Path to template file.
param: bool   $load_once      Whether to require_once or require. Default true.
param: array  $args           Optional. Additional arguments passed to the template.



Generated : Tue Dec 24 08:20:01 2024 Cross-referenced by PHPXref