Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

How to add a PHP page to WordPress?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

WordPress is one of the best blogging platforms. This is the scenario, we have a custom PHP page which we want to integrate with the WordPress blog. Our PHP file which we are getting to integrate might not use any of the WordPress APIs. Integrating PHP files with WordPress is very important for the back-end development of web design.

Step 1: Login to Microsoft Web Matrix 
The following screen appears. Open or create your WordPress template.

Step 2: 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/

Template Name: GFG
/* Rest PHP code here */

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 3: 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 “GeeksfoGeeks” listed in the dropdown. 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. Various types of templates can be created through it.

Example: In functions, you need to implement it as follows:

function simple_function_1() {
    return "Hello World!";
add_shortcode( 'own_shortcode1', 'simple_function_1' );

In post/page:



Hello World!

A real-time scenario is we will construct a sitemap page using this WordPress template option.

My Personal Notes arrow_drop_up
Last Updated : 05 Aug, 2020
Like Article
Save Article
Similar Reads
Related Tutorials