Can I use a wordpress theme in new php pages?

I’m putting together a web site that needed to include some signup and blogging capability. WordPress seems to be a perfect fit for that portion of the app, so I’ve started experimenting with it. I see plenty of tutorials on creating custom themes so I don’t expect that to be a problem.

What I’m not able to figure out is what to do with the rest of my site. I will have other non-blogging related php pages that will access a database, etc. I see that wordpress has a capability for generic pages of static content, but these would need to be coded PHP pages. I just can’t find a way of having the wordpress theme apply to other php pages outside of wordpress. I was hoping of just doing something like

Read More
wp_header();
blah blah
wp_sidebar();
blah blah
wp_footer();

but I’m not really seeing any examples or documentation on how this might be done. Am I missing a key piece of documentation?

EDIT: The answer is to essentially copy and paste a file from the theme, with one crucial addition:

require( dirname(__FILE__) . 'path_to_wp_root/wp-load.php');

That sets up the wordpress environment and allows me to call get_header(), get_sidebar(), get_footer(), etc.

Related posts

Leave a Reply

6 comments

  1. I think what you really want to do is include wp-load.php at the top of your php file. This will give you access to all the wordpress functions (wp-header(), wp-footer(), etc).

  2. Another option is to use WordPress as the CMS for all content on your site. This is increasingly becoming popular, as WordPress is quite good at non-blog-things these days.

  3.           define('STYLESHEETPATH', '');
              define('TEMPLATEPATH', '');
              $base = substr(__DIR__, 0,strrpos(__DIR__, '/[name of the dir where u store the php files]'));
              require_once($base."/wp-load.php");
              require_once($base."/wp-includes/pluggable.php");
    

    easy to use wordpress function outside