WordPress Custom Page Templates Not Displaying In Dropdown

Last night while working on a WordPress theme I came across an odd bug with some custom page templates not showing up in the drop down menu when creating a new page. Sadly there wasn’t any information about it in the WordPress documentation or at the support forum. An hour or so of searching later and I did find a solution and thought I would post about what I found in case you or someone out there runs into a similar problem.

Custom Page Template Problem

You may be aware that WordPress allows you to create your own page templates.

WordPress custom page template dropdown

The default Kubrik theme comes with two, the archives template and the links template, but you can create as many as you’d like.

These templates will be available to you in a drop down when create a new WordPress page or when editing an existing page as you can see in the dropdown to the left.

WordPress 2.7 seems to have an odd bug where some of your custom page templates won’t show up in the drop down and unfortunately my theme had been bitten by that bug.

While I was able to see some of the custom templates others were not visible at all in the template drop down and so were unavailable for use.

How To Get Your Custom Page Template To Show Up In The Drop Down

A little searching directed me to this post by Zach Graeve with a very simple solution. The trick Zach describes is to temporarily switch to another theme and then reactivate your theme. Doing that seems to reset the theme, kind of like rebooting your computer.

After a few more searches it seems as through the solution above works for most everyone. Alas, I’m not like most everyone and the solution didn’t work for me. Hopefully if you encounter this bug it works for you, since it’s about as easy as it gets to fix.

Back to searching which led me to another post on the missing dropdowns, by mkyong. The problem was the same and was occurring in version 2.5 of WordPress. The solution this time was going to the theme editor within the WordPress admin and select your page template to edit.

All custom page templates should start with the following code:

/*
Template Name: Custom Page Template Name
*/

which is a php comment that WordPress uses to identify page templates. In mkyong’s case and mine as well this bit of code was missing. What was particularly strange in my case was the code was in the file. That was the first thing I checked when I didn’t see the template listed in the drop down. Even stranger, I thought, was WordPress telling me I couldn’t save the file through the editor since the file didn’t have write permissions. Huh?

I checked permissions and indeed WordPress was right. How the permissions got that way is lost on me, but I set them back (755 for those of you who speak permissions) and I was able to add back in the php comment through the WordPress editor.

WordPress wouldn’t accept changes I made directly to the file in my usual code editor for whatever reason.

Once again all was right with the world or almost all right. WP still wouldn’t accept changes to the file through Coda, my editor of choice. When I opened things again tonight though, I seem to be able to make permanent changes in either editor and everything is indeed as it should be.

I realize most of you may never see this bug and perhaps stopped reading long ago, but this post is for the few of you who did encounter this problem and are having a hard time finding the solution. Hopefully you found this post and now know what to do.

Download a free sample from my book, Design Fundamentals.

101 comments

  1. Thank you fors posting this- I’ve just spent an hour on the same problem and you saved me a ton of time.
    Thank you again

  2. wow, I’ve been asking some so-call experts in my area about this, and they were like, o ,”the template pages always show up, try this fix”…which is the first fix u mention, it never works for me…well, thank you, finally, someone has the answer, lol..thanks!!

    I’m saving your site as a favorite, just for that!!!!!

    • I was bummed when I first tried to figure this out. The first fix about changing themes worked for one theme, but not the one I needed.

      A couple hours searching later and after trying a few things the permission fix did the trick. I had a feeling I might not be the only one having the problem either.

      The whole thing alerted me to a setting I needed to change in my FTP program which apparently was transferring files without the correct permissions.

  3. This was the answer to my problem! I have one issue that arised, however. My “hidden” code shows at the top of my page: http://signshoppe.org/wp/

    Right now, it’s camouflaged by my background, but if you look carefully, you can see “/* Template Name: Page with no Title */ ”

    Can you tell me what I did wrong? Thank you!

  4. My apologies for not seeing your comment sooner Allison. I looked at your site, but didn’t see the code you mention. Were you able to figure this out or do you still need help with it.

    I’ll be happy to take a look again if you still need help.

    The code you mentioned looks like it would be coming from the style.css file in your theme.

  5. Thanks this was very helpful. I read about the theme switching technique elsewhere but that didn’t work. Your solution with permission-tweaking however has done the trick. Cheers from South Africa.

    • I guess you had the same problem I did then. It turned out it was my code editor causing the permissions problem. The preferences had been set to not keep permissions of files when uploading in some cases. Once I found that and set things to keep the permissions I haven’t run into the problem again.

  6. WOOOOOOOW! What a great post! Steven you really made my evening. I just realized that I should do the same thing next time Im solving a problem that I cant find on google (which is quite often).

    Thanks for sharing!

    // Another guy who’s never like “most everyone”

  7. I love it when it simply and works. Thanks for the help.

    How can I create multiple “header files” because on some pages I want different header images.

    Can i just create copies of the header.php and then chnage the name?

    • Glad I could help Sam.

      You can show different headers in a couple of ways. One is like you suggest. You’d create copies of your header.php file with a different name, say header2.php. Then in your other theme files where you include header.php with the get_header() tag you could replace that with a simple php include to your new header2.php file.

      Another way to do similar is to use WordPress conditional tags to display different things on different pages. So you could have WordPress do something if the page is the home page and something else if it’s a single post. There are plenty of conditionals, which gives you a good deal of control.

      I tend to go the conditional route, but which option you go with depends on your situation.

  8. Yay!! Thanks for posting this. The bit of code was my problem! The initial solution didn’t work for me so I was getting frustrated. Thank goodness for this post :D

  9. Unfortunately, I have this bug, too.

    Resetting templates has not worked.

    My php code is perfect.

    The first 6 custom templates show, but nothing more. Permission settings are correct (I am ftp’ing from my local drive where I build templates anyhow.)

    Nothing works for me and I have about 3 hairs on my head left to prove it.

    Any other ideas? I am using WP as a CMS website not a blog and customizing my navigation is absolutely essential. Without being able to access my templates (which redirect to a static site) I find myself saying lots of bad words.

    • I didn’t notice the permission issue until I first tried editing the custom template through the WordPress interface for editing files. I had thought they were all fine until that point.

      Did you try to edit one of the templates that isn’t showing up through WordPress’s editor? If not try that. Try making a small change and saving the template file through the WordPress backend and then see if it either works or if you now see the incorrect permissions.

  10. I got the same problem last night with a client’s blog. I am actually just porting same blog to another domain with all the files and settings intact. Everything seems to work fine until I came to the point of setting up Home as my home page and couldn’t see the template there inside the editor panel. Searching for another solution, I came across your post. I will try it now. BTW, I’m running WordPress 3.0.

    • Let me know if the ideas here help. This was something that came about in 2.7 I think. My guess is the solution will work in 3.0, but you never know. Hopefully one of the solutions above will do the trick.

  11. Hey Steven,
    I am having a similar problem. However, the activate and re-activate didn’t work, neither did setting the permissions to 755. I went onto my host (godaddy) and even played around with the permissions in there and no luck.
    Any other suggestions or fixes you can think of?
    Thanks!

    • Everything I found about this is described in the post. One thing that seemed weird, but worked for me was to first attempt to edit the file through WordPress internal editor. The changes I made there didn’t take, but once I then changed permissions things did work.

      What version of WP are you using?

      Also while it should make sense maybe try the same things that didn’t work a few times. Sometimes that ends up working for me. A fix won’t work the first time, but it will when I try it a second or third time. No idea why that should work, but it sometimes does.

  12. This is an excellent post and thank you – definitely helped me!

    I’ve just updated to WP 3.0 and the problem seems to be on and off – not sure why. It’s more prominent on localhost (using XAMPP with Ubuntu) compared to when I’m working off the server live. Any ideas?

    The “soft-reboot” thing seems to sort it either way.

    • Thanks Rahul. Glad I could help in some way.

      I still haven’t updated, though I know I really should so I can’t speak to much about any issues with 3.0 yet. Interesting that it’s happening more locally. I wonder if it has something to with file paths. I know how I’ve set things up locally the paths can be different than what they are online.

  13. File paths is a great suggestion and I went back and had a look. I might be completely off the map here, but I tried moving XAMPP from /opt to another directory and the problem disappears.

    Could it be permissions? I gave the original XAMPP install in /opt full read-write (777) access and it works fine.

    I think maybe I’m dwelling too deep into this – but cheers for the help though! Saved me heaps of time! :)

    • Glad the file path suggestion helped. I suppose it could have been a file permission error too, but hard to know on this end. If /opt had full read/write there shouldn’t have been an permissions issue.

      At least you got it working. It would have been nice to know why, but getting everything to work was more important.

  14. Using 3.0.1. The comment method works for me. Thanks!

    However, the comment should read:

    as opposed to:

    /*
    Template Name: Custom Page Template Name
    */

    With the latter, the comment makes the custom template show up in the dropdown, but also adds the text “Custom Template” to the top of the page. This is hidden using the first method.

    Thanks for saving me so much time!

  15. Just realized that the correct comment seems to have hidden itself in my previous… response.

    Lets try it this way:

    Start with this:
    /*
    Template Name: Custom Page Template Name
    */

    And replace “/*” with “

  16. Glad this post was able to help. Sorry your comments aren’t coming through. If you want to send them to me via the contact form above I can probably fix your comments. I guess WordPress is eating one or more characters.

  17. I’m having this problem in 3.0.1 but I’m a bit confused by what people are saying in the comments as to what the handling is to this. I’m getting that this is due to that the comments being left have characters being eaten by WordPress. Is there a way you can edit the post with an update for 3.0.1’s solution, Steven? ;)

    • I’m glad you were able to get things working. Sorry I didn’t respond in time, but from the dates on your two comments it doesn’t seem like it too you too long to figure it out.

      Thanks for the link too. I cleaned it up a bit, since it was running to wide. :)

  18. Hi, i want to create a custom page within in a folder.
    how will it show up in the dropdown? coz it includes some images thats why i want to separate in a folder. hope you can help me out guys! thanks

    ex. mywptheme/mycustompage/mycustompage.php

    • Juan I’m not sure if it would show up in the dropdown if you place the file inside the folder. I’m not sure if WordPress will look inside any folder you create.

      Couldn’t you just place the images in a folder and keep the file with the rest of the theme files?

  19. Thanks for allowing get some much needed sleep as a result of your blog post. I could not figure out what the issue was until I came across you post, and trust me I had reactivated my theme so many times I lost count. That seemed to work for others, again thanks for being my resource on this issue!

    • Glad I could help you sleep Owen. This one kept me up one night and I figured I would collect some of the solution I found in one place so others like yourself could get more sleep than I did that night. :)

  20. Thank u so much, ustopped my frustration i had for over 2 days !!!!! thank you so much… None of my colleagues could help, very rare problem tough..

  21. Thank you so much for this! I found an interesting way to create custom templates for RSS feeds that Yoast wrote. I got it from here: http://www.wprecipes.com/creating-user-defined-rss-feeds-in-wordpress

    I changed the two lines:
    $posts = query_posts(‘showposts=’.$numposts);

    $lastpost = $numposts – 1;

    to be
    $posts = query_posts( ‘cat=26&tag=new-hampshire-links’ );

    $lastpost = $numposts – 1;

    and named the template ‘custom-feed-nh.php. But it would not show up in the list you describe.

    Now I changed the name to: Template Name: Custom Feed NH and it works perfectly.

    Thank you so much!
    Nancy

    • Glad I could help Nancy. This was one of those weird bugs that took me forever to figure out. I’m glad I’m able to save others some time.

      And I’ll second the vote for any code Yoast writes. He always has great stuff. :)

  22. Thanks for this.

    I wonder, were you using Subversion or any version control system? I had the same issue and it’s the first time I’ve run into the permissions not being set right, and I wonder if it’s because I created the file within my IDE’s Subversion extension.

  23. Chase, I haven’t used Subversion and it definitely wasn’t an issue for me with this problem. I have no idea why the permissions weren’t right, only that they weren’t. It was strange and it’s not something that’s come up again for me.

  24. Thanks for your post!

    It’s fun to see how this bug is still a problem in WordPress, even three years later.

    In my case the problem was caused for special characters in the description of the theme. Just a Ñ make the theme cant be recognized by WordPress.
    I found the solution here (in spanish)
    Hope this help to others.

    • Thanks for the link Gustavo. I’m kind of surprised this bug still exists, but I guess it still does. I never thought this post would last as long as it has when I first wrote. Glad it can still help people.

  25. I’m not sure if anyone is still having this problem, but one day it works for me and then it disappears. I have checked my permissions, switched themes around, and checked the php at the top of the page. I can’t figure out why my page templates will not show up.

    Is anyone else having this problem still?

    • Hi Kim,

      I haven’t been having this problem in recent versions of WordPress, though I don’t think it was ever a common problem. What version of WP are you using?

      Are these all regular posts where you sometimes see and sometimes don’t see the page template? Or are you seeing them on regular posts, but not on custom post types?

    • I figured out the problem. .. It was the user!! Something that I did (from this article) worked, but I was looking in the wrong place. Thanks.

      • Good to know. User error is often the case, isn’t it? :)

        Glad I could help and on the bright side I’m guessing if the same issues every comes up again you won’t have to look so hard to figure out what’s going on.

  26. Hey Guys,

    had the same problem, always saw templates and today don’t.
    found this post.

    my php code for template name was there, but it was a bit different.

    until wp 3.4 this code worked flawlessly

    after updating to wp 3.4 that code above stop working for some reason.

    so i did as mentioned above

    and it worked :D

    hope helps some of you out as well

    cheers

    • Hey Max. I’m glad something here helped. This is one of those weird issues. I don’t think it happens to most people, but when it does it’s hard to figure out what you’re supposed to do.

      I wasn’t aware it was still happening, but I guess it is. This was something I noticed back in 2.7 and even then it wasn’t something that happened to most. It seems every so often some leaves a comment saying they did have the problem and this post helped, so I’m glad I wrote about the issue when it happened to me.

    • Good to know John. I wonder if this issue is making a comeback with 3.4 being released. I hasn’t been out long and you’re the second person who mentioned having the issue. Maybe this post remains more relevant than I thought.

  27. Unbelievable. Just wasted an entire Friday evening trying to fix this….and wouldn’t have fixed it if not for this post and comments. Thanks all.

    A handful of my templates were showing but the majority weren’t. Tried everything.

    Changed:

    to:

    • Sorry about your evening, but glad the post and comments were able to help you find a solution.

      Your change didn’t come through. I assume it was code and WordPress ate it. If you want to email me what you did I can fix your comment to include the missing code.

  28. Thank you! I’ve spent almost 3 hours trying to fix this! Was about to just delete my whole site and start from scratch I was that frustrated! I had the exact same problem with Coda, although disconnecting and reconnecting now means my changes show up.

    • Glad I could help Tom. Seems like this is an issue again with the latest release of WordPress. Hopefully Google starts ranking the post better to save others those 3 hours many of us have spent trying to solve this problem.

      By the way did you get Coda 2? It took me a couple of days to get used to the new interface, but since I have, I’ve been liking 2 better than the original.

  29. I’m having this problem too but when I go to my ftp, there’s no file for the templates to edit – seems it’s either saving in the wrong place or not at all?

    Your help would be greatly appreciated

    • Have you created custom page templates? These aren’t default templates that come with every theme. They’re created custom either by yourself or whoever developed the theme. It’s possible your theme doesn’t have any custom templates.

      If you do they should have names like page-custom-name.php

  30. Hey,

    Thank you so much for this post! I am still trying to figure out how to access the permissions exactly if you could help me? I have created the custom template on the FTP but it still doesn’t show up on my dropdown menu even after updating the php code of teh first five lines and it says it’s saving fine but then doesn’t appear in a new page?

    Cheers,

    Niamh (newbie):)

    • Hi Niamh. I wasn’t aware this was still an issue. It’s not something I’ve run into in a few years. I guess it still happening though.

      By permissions I assume you mean the 755 thing I mentioned. Those are Unix permissions. Odds are your server is running on some version of *nix. Most FTP programs I’ve used will let you change the permissions. Usually you just right click on a file or folder and there’s an option in the context menu. It might say get info or something like that instead of specifically referring to permissions. The numbers refer to whether or not different groups of users can read, write, or execute the file or folder. Typically folders should be set to 755 and files to 644, though there are some exceptions.

      If your FTP program doesn’t give you access then you usually need SSH access to the server and you have to set permissions through unix commands. If that’s not something you want to do, you can probably give your host a call. They’ll often help with something like that.

  31. Adding
    /*
    Template Name: Custom Page Template Name
    */
    took care of my issue! Thank you so much for saving me from this headache. On a tight deadline this was the last thing I needed and I’m so happy to have found such a simple solution. Thank you so much!

    • Glad I could help Evy. It’s funny. I thought this post would have a limited lifespan as WordPress continues to upgrade. I think the basic problem I had was solved, but clearly not every problem regarding page templates has.

Leave a Reply

Your email address will not be published.

css.php