[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

Template loading functions.

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

Defines 21 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()
  locate_template()
  load_template()

Functions
Functions that are not part of a class:

get_query_template( $type, $templates = array()   X-Ref
Retrieve 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.

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

get_index_template()   X-Ref
Retrieve 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.
since: 3.0.0

get_404_template()   X-Ref
Retrieve 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.
since: 1.5.0

get_archive_template()   X-Ref
Retrieve 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.
since: 1.5.0

get_post_type_archive_template()   X-Ref
Retrieve 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.
since: 3.7.0

get_author_template()   X-Ref
Retrieve 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.
since: 1.5.0

get_category_template()   X-Ref
Retrieve 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.
since: 1.5.0
since: 4.7.0 The decoded form of `category-{slug}.php` was added to the top of the

get_tag_template()   X-Ref
Retrieve 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.
since: 2.3.0
since: 4.7.0 The decoded form of `tag-{slug}.php` was added to the top of the

get_taxonomy_template()   X-Ref
Retrieve 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.
since: 2.5.0
since: 4.7.0 The decoded form of `taxonomy-{taxonomy_slug}-{term_slug}.php` was added to the top of the

get_date_template()   X-Ref
Retrieve 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.
since: 1.5.0

get_home_template()   X-Ref
Retrieve 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.
since: 1.5.0

get_front_page_template()   X-Ref
Retrieve 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.
since: 3.0.0

get_privacy_policy_template()   X-Ref
Retrieve 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.
since: 5.2.0

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

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.
since: 1.5.0
since: 4.7.0 The decoded form of `page-{page_name}.php` was added to the top of the

get_search_template()   X-Ref
Retrieve 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.
since: 1.5.0

get_single_template()   X-Ref
Retrieve 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.
since: 1.5.0
since: 4.4.0 `single-{post_type}-{post_name}.php` was added to the top of the template hierarchy.
since: 4.7.0 The decoded form of `single-{post_type}-{post_name}.php` was added to the top of the
since: 4.7.0 `{Post Type Template}.php` was added to the top of the template hierarchy.

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.
since: 4.5.0

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
since: 4.3.0

get_attachment_template()   X-Ref
Retrieve 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.
since: 2.0.0
since: 4.3.0 The order of the mime type logic was reversed so the hierarchy is more logical.

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

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

return: string The template filename if one is located.
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         $require_once   Whether to require_once or require. Has no effect if `$load` is false.
param: array        $args           Optional. Additional arguments passed to the template.
since: 2.7.0
since: 5.5.0 The `$args` parameter was added.

load_template( $_template_file, $require_once = true, $args = array()   X-Ref
Require 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   $require_once   Whether to require_once or require. Default true.
param: array  $args           Optional. Additional arguments passed to the template.
since: 1.5.0
since: 5.5.0 The `$args` parameter was added.



Generated: Thu Mar 28 01:00:02 2024 Cross-referenced by PHPXref 0.7.1