How to make a php page and use a Wordpress theme
I want to create a special php and javascript page, but I want it to use my Wordpress theme that is already开发者_如何学C installed. How to do that?
Thanks
You can do this by including the header and footer from wordpress, and putting your own code in the middle. Such as this:
include $_SERVER['DOCUMENT_ROOT']."/wp-blog-header.php";
include $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/[YOUR THEME]/header.php";
// your code goes here
include $_SERVER['DOCUMENT_ROOT']."/wp-content/themes/[YOUR THEME]/footer.php";
I haven't tested this on newer versions of wordpress, but in the past that has worked. You can even include the wpconfig file if you want to use some of those variables, such as the database connection information.
Hope this helps.
See Integrating WordPress with Your Website « WordPress Codex on how to pull the header and other includes into a static php page/file, like:
<?php
require('/the/path/to/your/wp-blog-header.php');
get_header();
?>
<?php
define('WP_USE_THEMES', FALSE);
require('./wp-blog-header.php');
get_header();
query_posts('showposts=1');
get_footer();
?>
精彩评论