Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add php page in wordpress outside the theme

Tags:

php

wordpress

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.

like image 802
user3797045 Avatar asked May 14 '26 02:05

user3797045


1 Answers

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'); ?>
like image 89
Ram Sharma Avatar answered May 16 '26 16:05

Ram Sharma