user3797045
user3797045

Reputation: 29

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.

Upvotes: 3

Views: 1530

Answers (2)

Ram Sharma
Ram Sharma

Reputation: 8819

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'); ?>

Upvotes: 3

WpTricks24
WpTricks24

Reputation: 825

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');

Upvotes: 1

Related Questions