How to write a custom PHP page in WordPress?
June 21, 08 by the programmerWordPress is one of the most used blogging platform in the world.
It is very extensible throw the plugins and it is very easy to use.
However sometimes we need to make some custom pages that contain forms and other custom code that is more complicated to implement using plugins, it is much easier to implement them by simply creating a custom standalone wordpress page that will have all the wordpress standard headers footers, sitebars and everything else except that it will have a unique content.
This is very simple, all you have to do is create a PHP page in the WordPress root folder and copy the code bellow. That’s it .
The code bellow is very simple example of a page that contains a simple form with one text field and a submit button. When you click on the submit button the entered text will be displayed.
<?php
require_once ‘./wp-blog-header.php’;
get_header();
# CUSTOM CONTENT GOES HERE
$submited_value = $_REQUEST[’edb_text’];
$html_code = ‘
<div id=”content”>
‘.$submited_value.’
<form method=”post”>
<input type=”text” name=”edb_text” />
<input type=”submit” value=”Submit”>
</form>
</div>
‘;
print $html_code;
get_sidebar();
get_footer();
?>
Try it and have fun ![]()
