Add PHP page/template in WordPress

 

Step 1: Create WordPress Template Page

We can start with a sample file and copy page.php, rename it on your choice and put it inside the theme folder ../wp-content/themes/mytheme/

This new file should start with the following content and then followed by the custom PHP content. This is the WordPress template.

Remember to upload this to the theme folder. Now the WordPress template is ready.

Step 2: Create WordPress Page

Click the “Pages” link from the WordPress Dashboard. The template we created can be used to create this new page. We can give the Page name and choose the “Template” from the drop-down from the “Page Attributes” section. There the PHP-page we uploaded will come with the “MyNewTemplate” listed in the drop down.

 

Now publish. Here we go, we have created a WordPress PHP page using our custom code. Whenever this page is linked, our custom PHP code will get executed. We can create any number of WordPress pages using this template.

 

Leave a Reply

Your email address will not be published. Required fields are marked *