The way of creating full custom page for wordpress.

If you want to make one or more pages for wordpress that will be include only header, footer and common style of theme and you just started creating your first plugins for wordpress this article for you.

I just want to advise you use `template_redirect` filter and show how I realize it.

So idea is using filter to sort urls you need and use different templates in different ways. This is little bit difficult to understand but there is piece of code – just look at:

* Getting url for current page
* @see resource:
private function cur_page_url() {
$page_url = 'http';
if ($_SERVER["HTTPS"] == "on") {
$page_url .= "s";
$page_url .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
} else {
return $page_url;
function sap_template_redirect () {
// There is we get current url
$current_url = $this->cur_page_url();
if ( ... ) { // checking url
// if condition is match for us then we set our template
exit(include( ... ));
add_action('template_redirect', 'sap_template_redirect');

So you saw there `include()` with yourown template called by condition. Template is copy of index.php file from theme and change it what you want. For instance:

 * @package WordPress
 * @subpackage Default_Theme
get_header(); ?>
<div id="content" class="narrowcolumn" role="main">
	// There is code that you want to see here...
<?php get_sidebar(); ?>
<?php get_footer(); ?>

You need copy this file to your plugin’s folder and use it when you want it depend of url or any other condition.

Ask your questions and good luck!..

Books to read

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *