How to add a PHP page to WordPress?


If you want to add a custom page with PHP for your WordPress blog, we have a very simply solutions. Follow the instructions below:

Duplicate page.php in your theme folder (/wp-content/themes/your_theme/).

Rename the new file as for example page-custom.php (where custom is what you want to call your new template).

To add your new page to the list of available templates in pages, enter the following at the top of the new file:

Template Name: Custom Page

If you have this little code at the top of the new file, WordPress knows that this is a template and now you can modify this file as you want. Include other files, functions or whatever you need.

After that create a new page in your WordPress site. In the page editing screen you will see a Template dropdown in the Attributes widget to the right. Select your new template and publish the page. That is it!

Your new page will use your PHP code defined in page-custom.php

Add comment

Recent Posts


Recent Comments