Create a Custom Wordpress Page

Here is how you can add a custom page to Wordpress. This is useful if you want to create a page that uses your own code for a custom function and you want to use the template you have installed on your Wordpress blog.

So let’s get to it…

Create your custom page

For this example, <doc root>/test.php.

<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>

<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Update your .htaccess file

Update your .htaccess file to bypass redirection to the Wordpress controller.

It’s important to note that if you place any rules within the BEGIN/END Wordpress block they will be overwrtitten.

<IfModule mod_rewrite.c>
        RewriteEngine On
	RewriteBase /
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^test$ /test.php [L]
</IfModule>

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Add a new page in WordPress

Add a new page within WordPress and set the Permalink with the same URI as the page created otherwise the handle_404() class in classes.php will return a 404 status and your page will not be indexed by search engines.

Permalink: http://www.your-web-site.com/test

Now fire up your browser and verify everything works properly.

http://www.your-web-site.com/test

Resources

http://www.ideashower.com/learned/override-wordpress-htaccess-with-custom-rewrite-rules/

http://www.webpronews.com/blogtalk/2007/06/11/keep-wordpress-from-overwriting-custom-htaccess-rules

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Related Posts

Tags: , ,

Comments (1)

  1. I found your website looking for an answer to my question, may be you can help me?

    I’m using Windows Live Writer to update my Wordpress blog, and I don’t see a way to use a page template with WLW?! Do you happen to know how to use a page template with Windows Live Writer?

    Thanks in advance!

Leave a Reply





Donate

If you found this article useful and would like to see more like it this please consider making a donation.

Sponsors