WordPress Custom Page Templates Not Displaying In Dropdown

Steven Bradley

by Steven Bradley
on Friday, February 27th, 2009
in WordPress

«

»

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

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

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.

Spread some karma These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Mixx
  • StumbleUpon

Subscribe to TheVanBlog | Email This Post Email This Post

40 Responses to “WordPress Custom Page Templates Not Displaying In Dropdown”

MyAvatars 0.2
2009-03-11 19:27:27

Your post just saved me a ton of time. Thanks for writing this up.

MyAvatars 0.2
2009-03-13 13:54:29

Glad to help Lloyd. I spent a couple of hours trying to figure out what was wrong and had a feeling others might be struggling to find the information too.

 
 
MyAvatars 0.2
Xavier
2009-03-29 16:36:58

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

MyAvatars 0.2
2009-03-29 16:56:16

Glad I could help. I guess I wasn’t the only person encountering this problem.

 
 
MyAvatars 0.2
2009-04-02 04:15:36

Thanks for the article. I had the same permission problem as well. Glad it’s not a bigger problem than it seems.

MyAvatars 0.2
2009-04-14 13:41:25

Glad I could help. The permission thing was the same problem I had.

 
 
MyAvatars 0.2
2009-04-04 18:54:00

Adding another thank-you to the list. Switching themes on and off did the trick for me.

MyAvatars 0.2
2009-04-14 13:42:17

Glad to help Darren. Sounds like you had the easy fix. I’m not sure exactly when, but WordPress seems to have introduced the problem. Hopefully it’s sorted out in 2.8

 
 
MyAvatars 0.2
jh Subscribed to comments via email
2009-04-13 22:10:07

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!!!!!

MyAvatars 0.2
2009-04-14 13:44:53

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.

 
 
MyAvatars 0.2
Allison
2009-04-29 11:25:15

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!

 
MyAvatars 0.2
2009-05-03 02:40:55

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.

 
MyAvatars 0.2
Brian Andrews
2009-05-23 13:32:50

thanks so much. the theme reset didn’t work for me but the comment did the trick.

MyAvatars 0.2
2009-05-28 14:36:17

Glad I could help.

 
 
MyAvatars 0.2
Kosta
2009-05-26 01:13:05

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.

MyAvatars 0.2
2009-05-28 14:38:51

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.

 
 
MyAvatars 0.2
2009-06-12 10:31:16

Huge help, thanks!

 
MyAvatars 0.2
Jay
2009-06-18 15:44:32

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”

MyAvatars 0.2
2009-06-23 15:31:49

Glad I could help. This was so frustrating for me the night I encountered it and I figured I could combine my searching into a post.

 
 
MyAvatars 0.2
Tim
2009-06-20 06:31:01

I want to give you a hug!! You saved me hours!! Thank you.

MyAvatars 0.2
2009-06-23 15:32:21

Glad to help Tim. I hoped this post would do exactly that.

 
 
MyAvatars 0.2
Jonathan Subscribed to comments via email
2009-06-25 11:09:38

Thank you so much for posting. You saved me a lot of work!

MyAvatars 0.2
2009-07-01 12:28:40

Glad I could save you some work Jonathon.

 
 
MyAvatars 0.2
2009-07-03 04:55:12

Thanks for the instructions! Now I can *finally*
get back to making that custom page template.

 
MyAvatars 0.2
sam Subscribed to comments via email
2009-08-05 14:59:17

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?

MyAvatars 0.2
2009-08-05 15:16:13

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.

 
 
MyAvatars 0.2
2009-08-06 01:56:38

Thanks a ton buddy ! It really saved some time for me.

MyAvatars 0.2
2009-08-21 11:39:10

Glad to help.

 
 
MyAvatars 0.2
2009-08-25 19:53:45

Thanks, that was exactly what I was looking for.

Thanks for sharing.

MyAvatars 0.2
2009-12-15 12:32:03

Glad I could help Leigh.

 
 
MyAvatars 0.2
2009-12-10 10:41:16

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

MyAvatars 0.2
2009-12-15 12:33:12

The initial solution didn’t work for me either. I had to go all the way down to the last. It was definitely frustrating. Hopefully this posts helps reduce that frustration for others.

 
 
MyAvatars 0.2
Ash
2010-01-16 10:58:07

thanks for the tip. my template dropdown wasn’t showing at all. I did the siwtch to another theme and switch back and fixed it.

MyAvatars 0.2
2010-01-18 14:32:27

Glad I could help. I wish it had been that easy for me, but then again had it been easy this post probably wouldn’t exist.

 
 
MyAvatars 0.2
John
2010-02-16 15:03:48

I had the same problem (using wp latest version 9.2.2!)
You saved my time. Thanks

MyAvatars 0.2
2010-03-01 13:20:58

Glad I could help John.

 
 
MyAvatars 0.2
2010-02-25 16:46:04

You are amazing! Thank you!!!

MyAvatars 0.2
2010-03-01 13:21:25

Thanks Brad. Glad I could help.

 
 
MyAvatars 0.2
2010-03-12 06:40:48

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.

MyAvatars 0.2
2010-03-15 13:37:23

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.

 
 


Name (required)
E-mail (required - never shown publicly)
URI
Your Comment

Subscribe

Search TheVanBlog

Recommended

Small Business Forum Teaching Sells Free Report

SEO Book Training

Popular Posts