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

Recent Articles

How to Get WordPress Post Featured Image URL

Are you a WordPress developer or an advanced WordPress user? Whoever you are, sometimes you may need the direct URL of a...

How to Bulk Delete Media in WordPress

WordPress and media. That's the topic for a book. Sometimes is not easy to find what you need and when you have...

Custom Order Number for WooCommerce Will Saves You a Lot of Hassle!

WordPress is still the king of Content Management Systems (CMS). Thanks to its open-source nature, millions upon millions of users and PHP...

How to Manually Sort WooCommerce Products

WooCommerce is an e-commerce plugin for WordPress. It is a great way for the user to create an online store for their...

How to Delete All WooCommerce Products

Remove all WooCommerce products is a good thing, especially when you have got thousands of products and need to make your site...

Get in touch

Be our first-class reader, build a community and follow us on social media!

Leave A Reply

Please enter your comment!
Please enter your name here