Title: Custom php template
Last modified: October 25, 2024

---

# Custom php template

 *  Resolved [mdufauloomi](https://wordpress.org/support/users/mdufauloomi/)
 * (@mdufauloomi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/)
 * Hello,
 * I’m trying to create a new template for my page in my theme. I’ve created a test.
   php file, in my templates folder, along with my others template pages in html.
 * I’ve followed the [official tutorial](https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use),
   but my php template isn’t showed in my template list on my wordpress editor. 
   Does anyone know why ? What can I do ?
 * Here is my test code :
 *     ```wp-block-code
       <?php/*Template Name: Test Template*/?><h1>This is a test</h1>
       ```
   
 * Thanks in advance !
    -  This topic was modified 1 year, 7 months ago by [mdufauloomi](https://wordpress.org/support/users/mdufauloomi/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Karthikeya Bethu](https://wordpress.org/support/users/karthikeya01/)
 * (@karthikeya01)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/#post-18095631)
 * The tutorial you are referring to is for classic themes. Please follow the below
   page to create a template for block theme, as all your files are .html your template
   is a block based template.
   [https://developer.wordpress.org/themes/templates/templates/#custom-templates](https://developer.wordpress.org/themes/templates/templates/#custom-templates)
   Please reach out if you have any doubts.Thank You
 *  Thread Starter [mdufauloomi](https://wordpress.org/support/users/mdufauloomi/)
 * (@mdufauloomi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/#post-18095657)
 * Thanks for your anwser !
 * I wanted to create a template file in php, because I want to add php code in 
   this specific template. Is there a way to easily switch the “type” of my theme(
   from block based to classic themes) ? Or should I use a shortcode to add my php
   code to my template ?
 *  [Karthikeya Bethu](https://wordpress.org/support/users/karthikeya01/)
 * (@karthikeya01)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/#post-18095682)
 * [@mdufauloomi](https://wordpress.org/support/users/mdufauloomi/) If you want 
   to use PHP code, In my opinion the best way is to create a pattern and include
   it in your template.
   [https://developer.wordpress.org/themes/patterns/](https://developer.wordpress.org/themes/patterns/)
 *  [Karthikeya Bethu](https://wordpress.org/support/users/karthikeya01/)
 * (@karthikeya01)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/#post-18096450)
 * [@mdufauloomi](https://wordpress.org/support/users/mdufauloomi/) You can also
   follow this article to create custom php templates in block theme
   [https://fullsiteediting.com/lessons/how-to-use-php-templates-in-block-themes/](https://fullsiteediting.com/lessons/how-to-use-php-templates-in-block-themes/)
 *  Thread Starter [mdufauloomi](https://wordpress.org/support/users/mdufauloomi/)
 * (@mdufauloomi)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/#post-18100144)
 * Thank you for you answer ! As I wanted to use information from my post in my 
   template, I couldn’t use a pattern with php, but they mentioned [this documentation](https://developer.wordpress.org/news/2024/02/20/introducing-block-bindings-part-1-connecting-custom-fields/)
   instead, so I used Block Binding with custom fields and it worked as excepted!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Custom php template’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 2 participants
 * Last reply from: [mdufauloomi](https://wordpress.org/support/users/mdufauloomi/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/custom-php-template/#post-18100144)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
