简体   繁体   中英

Add php page in wordpress outside the theme

I have added a php page ( test.php ) in my root directory (WWW) where wordpress is installed. I don't want to use the custom template method (add this page in my wordpress theme directory) I have added in this php file this:

<?php
require('wp-blog-header.php');
get_header();
?>
<h1>Test</h1>
<?php
get_footer();
?>

When I do: www.example.com/test.php this page is correctly loading but the title of this page display " error 404 "

I don't understand how can I resolve this problem.

you need to include wp-load.php to use header, in your case replace require('wp-blog-header.php'); with

<?php require_once('wp-load.php'); ?>

I have placed this code in my root directory in test.php file. This code is working fine if you replace require('wp-blog-header.php'); with require_once('wp-load.php');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM