I am trying to update a page template, and when I do something strange happens. Let me explain..

I have a template "Hat Size Guide" where the code file is /themes/my-theme/pages/page-hat-size-guide.php

I am trying to update that php file to include a hyperlink, and when I do the pages that had this template set no longer have this template set: I go to edit a page that uses this template and the Template is automatically set to "Default". Also when I try to set the template back to "Hat Size Guide", all of a sudden all my custom fields for this template are gone. Now when I restore the php file back to what is was, everything is restored to what it was.

I have even tried to just update the php file with a simple

<div id="testingdiv">testing</div>

and I get the same results. This is driving me mad! Does anyone know why this is happening?

Template file: page-hat-size-guide.php

  • Check the top of the file, in the comment section and make sure it follows Template Name: Hat Size Guide (in comments of course)
    – bynicolas
    Aug 11, 2016 at 18:43
  • @bynicolas It does indeed Aug 11, 2016 at 18:46
  • could you share your template code, there must be something conflicting elsewhere within that file!
    – bynicolas
    Aug 11, 2016 at 18:53
  • @bynicolas For sure, I added a link to the file. The only change I've made to the file is the awesomediv @ line 72. Aug 11, 2016 at 19:35
  • What app are you using to edit the file? Could be an encoding or file type problem? Sounds very strange. If the "Template Name" value does not change, WP should use the current version of the file. No need to re-assign it to pages that were using it before the edit. What template DOES get assigned when the original is removed from the page? Perhaps there is a clue in that behavior.
    – jdm2112
    Aug 11, 2016 at 19:49

1 Answer 1


Check if you have any white space below your code. You might have a "Japanese" white space Character. Anything else I can think of? I need 50 rep points to comment on this topic. Make sure to use unicode File transfers from Windows.

  • Thanks. I mentioned in comments above but I'll note here for you as well. Even just copying the file within the linux web server causes it to break. On the web server, I just simply cp page-hat-size-guide.php page-hat-size-guide_bu.php and use the copied file and it breaks it... Is that weird or what? Aug 11, 2016 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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