Page Template issue in WordPress – Line endings

Building some of the design modules for the new design of, I ran into a nasty problem today. Most of the customized pages I have going in my web pages are php stuff that is included into the WordPress engine … by sneaking them in as page templates. That way I am able to publish pages with dynamic content totally under my control.  (One example is a page with the requirements for a belt test that changes after the user has selected his/her current belt grade).

Now, I use it for a lot of stuff so it is important to have this basic functionality in place. Nevertheless, I was surprised to learn that the first thing I did after the WordPress upgrade failed completely.

  1. I wrote a php page called pg_morenews.php in my editor on the Mac OSX platform – a freeware editor called Smultron.
  2. Then included the following 5 lines in the beginning of the file:
    Template Name: pg_morenews
  3. Uploaded the new file to the themes directory on the WordPress system.
  4. Wrote a new page in the WordPress interface with the name “More News” and an error message in the text field. Under normal circumstances, I never expect anybody to see this anyway.
  5. Finally I wanted to set the page template dropdown box to my newly created php file.
    Oh horror – no customized template present in the dropdown box.


Becoming increasingly worried this might be a new side effect of installing version 2.5.1, I searched the WordPress support forum that typically is an excellent source of help and inspiration in situations like this. Only to learn that other people had discovered a similar problem. Enough people for a two page comment thread even…

The recommendation on the forum were along the lines of clearing the cache by switching to the standard design and back, check file permission, file naming, template lines syntax and finally the one that helped me by mantis2008 about the Mac OS line endings in the editor.

Thanks to mantis2008 – after setting the line endings in Smultron everything worked as I expected.

In Smultron this is done using the Text Menu, then select Line endings/Dark Side (CRLF). After uploading the pg_morenews.php file once again and refreshing the page with the drop down box, it was there.