Support » Fixing WordPress » Header Code to Make Admin Preview Work

  • Resolved markroth


    I have created a php-free template to generate my original hand-coded static-html home page.

    A problem I have is post/page prepublication admin previews show the home page, the the post/page to be previewed.

    In other words, everything after the question mark in the URL is ignored.

    My assumption is that I need to add some wp-related code to my home page so post/page admin previews work properly.

    I have done a lot of searching…unsuccessfully.

    Which line(s) of code from the header do I need to include to get this pre-pub admin preview working?


    • This topic was modified 2 weeks, 1 day ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Joy


    I can’t tell what you are referring to.
    There is a preview in the editor and there is a preview in the Customizer. Which one are we talking about?
    Also, when you say “php-free template”, do you mean a template file in your theme or a reusable block or a HTML file in your home directory?

    Thank you for your reply, Joy.

    I’m sorry about my lack of specificity in those regards.

    I’m talking about the preview in the editor and a template for my child theme.

    This single-use template is for the home page. It does not use WP header, footer, content, sidebar, or any such. (This is a stop-gap measure until I have the time to develop something different that’s entirely WP.)

    Well, an unanticipated result of going this route is that when I want to preview an unpublished post or page, it displays the home page.

    I assume that’s because the header is missing whatever WP code it takes to display the unpublished post/page instead. So I would like to add that code to my template without getting any of the other header code.



    OK, I tried to reproduce what you are seeing and failed. Perhaps my test is not what you have?
    I don’t have any plugins that do redirection, I have a normal .htaccess file, the theme doesn’t do anything weird. I made a child theme that does nothing but hold a template named my-static.php. It contains the bare minimum for making a page. It has to have one php tag in order to have the template comment marker or I wouldn’t be able to select it in the editor.

     * Template Name: My Static
    <!DOCTYPE html>
    <p>This is my page. Ain't it great?</p>

    I set my home page to an existing Page and in the editor, assigned the new page template.
    Clicking on Update to save the template choice, I can then click on Preview and see the content of my-static template as expected. I go to the Page list and Post list and any existing pages/posts show correctly in the editor and the preview. I click on Add New Page and type something. Click on Preview and it shows what I typed. Same for Posts.
    I just don’t see what you are saying happens. This was tested with WP 5.2.7 and WP 5.4.2, both editors.

    So, what about my setup is different from yours besides the HTML of the static template?



    Wow, Joy! You have gone to a lot of bother to be helpful. I’m incredulously appreciative of that.

    Alas, I’m here to eat humble pie. I’m chagrined, dismayed, mortified, and so forth.

    All that time and effort you invested was not necessary…because of an oversight of mine. I am very, very sorry. 🙁

    All the hours I spent trying this and trying that, and all the hours I spent looking there and looking here, were not necessary…because of an oversight of mine.

    I forgot to delete the original index.html from the root directory! After reading your previous message and seeing that what you did was essentially what I did…it suddenly hit me that I’d forgotten index.html. I renamed it…and preview works.

    Valuable lesson for me to learn. I’m sorry it cost you too. 🙁

    Grateful for your time and help,



    That’s actually funny, because my first answer I was typing was an explanation of how the index.html and index.php files can be designated in a different order, and which did you do, etc.
    I reread your question and decided you weren’t doing that, so I changed my answer.
    But testing your scenario made me see some strange error with a child theme of mine, which I am still investigating, so thanks!

    Thank you, Joy, for your gracious reply. 🙂

    Just in case anyone ever sees this thread and thinks it might address a problem they’re having, I just did a blog post explaining what I did: Create a Custom WordPress Page Template for HTML Content. 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.