0

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?

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

1 Answer 1

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.

1
  • If you're not using a custom from-scratch theme, make sure to create a child theme. If you just add a file to an existing theme, the next time you update that theme, it may disappear. But if you build it as a child theme, which just requires creating a style.css file with a few comments, you can still update your original theme without wiping out your own templates and changes.
    – WebElaine
    Commented Feb 4, 2020 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.