get_page_templates

函式
get_page_templates ( $post = null, $post_type = 'page' )
引數
  • (WP_Post|null) $post Optional. The post being edited, provided for context.
    Required:
    Default: null
  • (string) $post_type Optional. Post type to get the templates for. Default 'page'.
    Required:
    Default: 'page'
返回值
  • (string[]) Array of template file names keyed by the template header name.
定義位置
相關方法
get_page_templateget_paged_templateget_page_template_slugget_tag_templateget_date_template
引入
1.5.0
棄用
-

get_page_templates函式是一個WordPress函式,用於檢索當前主題中可用的頁面模板陣列: 這個函式不接受任何引數: 該函式返回一個可用的頁面模板陣列,其中鍵是模板的檔名,值是模板的名稱,因為它們應該顯示給使用者。

獲得該主題中可用的頁面模板。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_page_templates( $post = null, $post_type = 'page' ) {
return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}
function get_page_templates( $post = null, $post_type = 'page' ) { return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) ); }
function get_page_templates( $post = null, $post_type = 'page' ) {
	return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}

常見問題

FAQs
檢視更多 >