Have you ever put together a cool script or page on your own, and then wanted to integrate it into WordPress so it would have the same look and feel as the rest of your site?
Maybe you have a custom survey you put together with PHP, or a web directory, a Job Board, or some other thing that you can’t really do inside WordPress.
Here’s a bit of code that will help integrate your script with your theme, and will also make other internal WordPress functions available to your script:
<?php
require('../wp-load.php');
get_header();
?>
Your page content here.
<?php get_footer(); ?>
Easy enough? Just make sure the require
statement points to the correct path of wp-blog-header.php. This example assumes that your script is inside a directory rather than the root (e.g. /myscript/index.php). If your script is in the same directory as wp-blog-header.php, just change the “../” to “./” ans you’re all set.
Whenever your page is loaded, WordPress will be called upon as well, and your theme will be added in around your script. There’s a small chance that WordPress may conflict with your script though, so be sure to test and change any variables and functions that interfere with WordPress’s internals.