get_query_template

Sponsored Link

拡張子を使用せずにファイルのパスを取得します。

ファイルの拡張子を含まないファイルのパスを直接取得するために使用します。locate_template()の使用でファイルが存在する場合、親テンプレートのチェックもします。他のget_*_template()関数の使用することなくより汎用的なファイルの場所が可能となります。

パスを取得するためにinclude()あるいはrequire()を使用することができます。

Sponsored Link

Retrieve path to file without the use of extension.

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

Can be used with include() or require() to retrieve path.

   if ( '' != get_query_template( '404' ) )
   include( get_query_template( '404' ) );

または同様に下記で行うことができます。

or the same can be accomplished with

   if ( '' != get_404_template() )
   include( get_404_template() );

get_query_templateのファンクションタグ使用方法

<?php get_query_template( $type ) ?>

get_query_templateのパラメーター

$type

(string) (required)拡張子なしのファイル名。
デフォルト:なし

(string) (required) Filename without extension.
Default: None

戻り値

(string)
ファイルへのフルパス。

(string)
Full path to file.

注釈

  • 用途: locate_template()から結果に”{$type}_template”のapply_filters()。
  • 用途: “{$type}.php”のlocate_template()。
  • Uses: apply_filters() on “{$type}_template” on result from locate_template().
  • Uses: locate_template() on “{$type}.php”.

変更ログ

Since: 1.5.0

ソースファイル

get_query_template()は、wp-includes/theme.php内に位置しています。

get_query_template() is located in wp-includes/theme.php.

Sponsored Link