How can I add PHP page to WordPress

0 votes

I want to create a custom page for my WordPress blog that will execute my PHP code in it, whilst remaining a part of the overall site CSS/theme/design.

The PHP code will make use of third-party APIs (so I need to include other PHP files).

How do I accomplish this?

May 8, 2020 in PHP by kartik
• 37,510 points
1,085 views

1 answer to this question.

0 votes

Hii @kartik,

First, duplicate post.php or page.php in your theme folder.

Rename the new file as templatename.php (where templatename is what you want to call your new template). To add your new template to the list of available templates, enter the following at the top of the new file:

<?php
/*
Template Name: Name of Template
*/
?>

You can modify this file (using PHP) to include other files or whatever you need.

Then create a new page in your WordPress blog, and in the page editing screen you'll see a Template dropdown in the Attributes widget to the right. Select your new template and publish the page.

Your new page will use the PHP code defined in templatename.php

Hope this work!!

Thank You!!

answered May 8, 2020 by Niroj
• 82,880 points

Related Questions In PHP

0 votes
1 answer

How do I add PHP code/file to HTML(.html) files?

Hello @kartik, You can't run PHP in .html ...READ MORE

answered Oct 22, 2020 in PHP by Niroj
• 82,880 points
513 views
0 votes
1 answer

How can I get PHP to produce a backtrace upon errors?

Hello @kartik, My script for installing an error ...READ MORE

answered Nov 5, 2020 in PHP by Niroj
• 82,880 points
811 views
0 votes
1 answer

How can I use PHP to check if a directory is empty?

Hello @kartik, It seems that you need scandir instead of ...READ MORE

answered Nov 10, 2020 in PHP by Niroj
• 82,880 points
8,704 views
0 votes
1 answer

How can I get PHP to produce a backtrace upon errors?

Hello @kartik, This is how you do it: set_error_handler(function($errorType){ ...READ MORE

answered Nov 14, 2020 in PHP by Niroj
• 82,880 points
403 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
21,750 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,880 points
2,647 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
2,504 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,880 points
41,372 views
0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,880 points
4,894 views
0 votes
1 answer

How can I use jquery $.ajax to call a PHP function?

Hello @kartik, Use $.ajax to call a server context (or ...READ MORE

answered Aug 27, 2020 in PHP by Niroj
• 82,880 points
14,032 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP