{"id":26381,"date":"2016-05-22T03:21:58","date_gmt":"2016-05-21T21:21:58","guid":{"rendered":"https:\/\/www.usefulblogging.com\/?p=26381"},"modified":"2025-02-18T00:47:11","modified_gmt":"2025-02-17T18:47:11","slug":"add-php-page-wordpress","status":"publish","type":"post","link":"https:\/\/www.usefulblogging.com\/add-php-page-wordpress\/","title":{"rendered":"How to Add a PHP Page in WordPress"},"content":{"rendered":"\n<p>Do you want to create a custom PHP page in WordPress blog that will execute you PHP code in it, whilst remaining a part of the overall site CSS\/theme\/design? This article will show you how to add a PHP page in WordPress. Your custom PHP page template is like any other theme file in WordPress. You can add any HTML, template tags, or PHP code in this file. The easiest way to get started with your <strong>custom page<\/strong> is by copying the existing page template provided by your theme. The PHP code will make use of 3rd party APIs (so you need to include other PHP files).<\/p>\n\n\n\n<p><strong>You don&#8217;t need to interact with the API, or use a plugin.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-add-a-php-page-in-wordpress\">Add a PHP Page in WordPress<\/h2>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>First, duplicate <em>post.php<\/em> or <em>page.php<\/em> in your theme folder (under \/wp-content\/themes\/themename\/).<\/p>\n\n\n\n<p>Rename the new file as <em>templatename.php<\/em> (where templatename is what you want to call your new template!). Enter the following at the top of the new file:<br><code><br>\n&lt;?php<br>\n\/*<br>\nTemplate Name: templatename<br>\n*\/<br>\n?&gt;<br>\n<\/code><br>You can modify this file (using php) to include other files or whatever you need.<\/p>\n\n\n\n<p>Then create a new page in your WordPress blog, and in the page editing screen you&#8217;ll see a &#8216;<strong>Template<\/strong>&#8216; dropdown in the &#8216;<strong>Attributes<\/strong>&#8216; widget to the right. Select your new template and publish the page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-final-words\"><strong>Final Words<\/strong><\/h3>\n\n\n\n<p>Your new page will use the php code defined in <em>templatename.php. <\/em>I hope you enjoyed this article if so, please share it with others. <em><br><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you want to create a custom PHP page in WordPress blog that will execute you PHP code in it, &#8230; <a title=\"How to Add a PHP Page in WordPress\" class=\"read-more\" href=\"https:\/\/www.usefulblogging.com\/add-php-page-wordpress\/\" aria-label=\"Read more about How to Add a PHP Page in WordPress\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":26382,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[127],"tags":[812,479,10],"class_list":["post-26381","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-page","tag-php","tag-wordpress","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-33","no-featured-image-padding"],"_links":{"self":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/26381","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/comments?post=26381"}],"version-history":[{"count":0,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/posts\/26381\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/media\/26382"}],"wp:attachment":[{"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/media?parent=26381"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/categories?post=26381"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.usefulblogging.com\/wp-json\/wp\/v2\/tags?post=26381"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}