THE BLOG


Quick Tip: How To Enable Wordpress Features On Non-Root Pages

Sep 11th '08
Alex Coleman

No Comments

Sometimes you have a page you’d like to add your side bar, recent posts or archives on. One problem, it’s not in the same directory as Wordpress. If this page is not in the Wordpress directory, this page will not work. You’ll get an error for every piece of PHP code referring to a Wordpress function. This quick tip will show you how to overcome this issue and have Wordpress features on a non Wordpress page.

For demonstration purposes, let’s edit an imaginary file called “thankyou.php”. This file will be hosted in the root directory on the web server, not in your theme directory in Wordpress. I’d like to include the sidebar on this page, but it keeps erroring out, saying the sidebar function is not supported.

When editing the file you want to display the sidebar on (this case “thankyou.php”), insert this snippet of PHP code to the top:

<?PHP require_once('wp-blog-header.php'); ?>

Yep, that’s it! Of course the location of that file will vary on your current situation, but if that’s the case, just link it accordingly.


Like This? Share It With The World!

  • del.icio.us
  • Digg
  • StumbleUpon
  • Design Float
  • E-mail this story to a friend!

Tags: , ,

Leave a Comment