Create a Custom WordPress Page

November 20th, 2008 | Posted in Wordpress
1

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

Related posts

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