WordPress doesn’t load templates that way.
First: give the template a name:
To load a page template, first you’ll have to make sure your template has a name. To do that, you’ll have to have the following CODE in your template file (here mypage.php
):
<?php
/**
* Template Name: My Page
*/
Once you have the above PHP comment, WordPress will recognise it as a template file.
Then, assign the template to a page:
Now you’ll have to create a WordPress page
(from wp-admin
).
While you create the page
, WordPress will give you the option to choose a custom template (if there is one). After you choose the template and Publish
, that page will use your mypage.php
file as a template.