Simmons Consulting, the Website of Toby Simmons

Integrating WP in external PHP pages

24
Jun

I have several external pages that use the WP theme engine to wrap the content. I use the method found here, which worked great under WordPress 2.9.2. After upgrading to WP 3.0, these pages no longer worked as expected but instead generated 404s; it turns out the fix is rather simple.

The code to include the WP theme in external pages used to look like this:

< ?php
  1. require('./wp-blog-header.php');
  2. get_header();
  3. ?>
  4. <h2>This is the external content.</h2>
  5. < ?php
  6. get_sidebar();
  7. get_footer();
  8. ?>

The newest version of WP merged the old WordPress Multi-User (WPMU) and the standalone version of WordPress. Since this merger, the new way to include WP in external pages is to change the require() statement to pull in wp-load.php (instead of wp-blog-header.php) like this:

< ?php
  1. require('./wp-load.php');
  2. get_header();
  3. ?>
  4. <h2>This is the external content.</h2>
  5. < ?php
  6. get_sidebar();
  7. get_footer();
  8. ?>

Now your external pages work just like they used to! I found the answer on a BBPress forum post from nine months ago.

One Comment »

  1. Arnold says:

    Interesting…
    One question, have you publish a video as tutorial. If yes please let me know
    thank u.

Leave a Reply to Arnold

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>