HTTP/2 301
server: nginx
date: Fri, 26 Dec 2025 11:37:41 GMT
content-type: text/html; charset=UTF-8
x-olaf: ⛄
vary: accept, content-type
x-redirect-by: WordPress
location: https://developer.wordpress.org/reference/functions/get_page_templates/
x-frame-options: SAMEORIGIN
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
HTTP/2 200
server: nginx
date: Fri, 26 Dec 2025 11:37:42 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-olaf: ⛄
vary: accept, content-type
link:
; rel="https://api.w.org/"
link:
; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
x-frame-options: SAMEORIGIN
content-encoding: gzip
alt-svc: h3=":443"; ma=86400
x-nc: MISS ord 1
get_page_templates() – Function | Developer.WordPress.org
get_page_templates( WP_Post|null $post = null, string $post_type = 'page' ): string[]
Gets the page templates available in this theme.
$postWP_Post|nulloptionalThe post being edited, provided for context.
Default:null
$post_typestringoptionalPost type to get the templates for. Default 'page'.
Default:'page'
string[] Array of template file names keyed by the template header name.
| Version | Description |
|---|
| 4.7.0 | Added the $post_type parameter. |
| 1.5.0 | Introduced. |
Output a list of available templates
The following code snippet loops through the available page templates and outputs their template names and the filenames.
Returns: