admin管理员组

文章数量:1392110

I created a custom page to show data from the DB for an intranet site I have created. I used the following

define('WP_USE_THEMES', false);
require('../wp-blog-header.php');
get_header();

I read this in the documentation to get my menus and header to show. (makes sense)

The issue is that it is showing in the title bar "page not found". The content loads and everything looks fine other than that.

Anyone have any fixes for this?

I created a custom page to show data from the DB for an intranet site I have created. I used the following

define('WP_USE_THEMES', false);
require('../wp-blog-header.php');
get_header();

I read this in the documentation to get my menus and header to show. (makes sense)

The issue is that it is showing in the title bar "page not found". The content loads and everything looks fine other than that.

Anyone have any fixes for this?

Share Improve this question asked Feb 3, 2020 at 22:17 ellucidoneellucidone 11 bronze badge 3
  • 1 Why not create this as a WP Page? It would be easier than just using an orphaned PHP file and then trying to include things from there. You could create a custom Page Template if you're wanting a different layout than the standard. – WebElaine Commented Feb 3, 2020 at 22:35
  • @WebElaine I have tried adding my custom PHP script to a page but it does not come out looking correct. Any ideas? Suggestions? – ellucidone Commented Feb 3, 2020 at 22:37
  • 3 I figured out whaqt you meant. This works great. I created a page inside my theme and then selected that as a template. Thank you – ellucidone Commented Feb 3, 2020 at 22:48
Add a comment  | 

1 Answer 1

Reset to default 0

ok so I figured this out. Here are the steps I took

Create a php file in your themes directory

wordpress Dir -> Themes -> YOUR THEME NAME -> newfile.php

In this file add the following:

<?php /* Template Name: theme-child */ ?>

<?php get_header(); ?>

// your custom script here 

<?php get_footer(); ?>
**Then go to Pages -> New Page

Within the new page on the sidebar select template and look for your template name that you defined in the top of the custom file.

Name and publish your page. Viola you should have a live page with your custom code in it.

本文标签: wp headCustom page with WP Header showing Page not found title