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 find WooCommerce products in the database

Hey, where in the database (or phpMyAdmin) are my WooCommerce products stored? Sometimes you may have some reason to find directly any...

Why is WordPress Asking For Your FTP Credentials to Install Plugins?

You want to install any plugin, but *blink* - WordPress need your FTP credentials. What the hell? The problem is simple -...

Fix PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

This error is getting probably when you trying to upload an import on WordPress on your XAMPP local dev environment, right? Well,...

How to Hide Shipping Methods in WooCommerce?

This is a small detail, but WooCommerce doesn't have built-in any function for hiding shipping methods based on different situations. Imagine when...

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...

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