6

Update: As with so many mysteries, the cause turned out to be extremely stupid. I had the file saved in a different theme's directory. Thanks to @a4jp.com

I'm building a theme using underscores. I've created a template file and added a template header at the top.

<?php 
/**
* Template Name: Featured
**/
get_header(); ?>

I'm not getting a Template drop down under Page Attributes in the page editor, so I'm not sure if there's a problem with my formatting or something else.

I did try switching themes. The drop down appears in the other theme, but when I switch back to my custom theme, it's still missing.

  • 1
    What is the name of your template file? e.g. you shouldn't prefix your template name with page- since that is a reserved format. – TheGentleman Apr 13 '15 at 20:11
  • It's name template-based.php – Thomas Martin Apr 13 '15 at 20:15
  • @GentlemanMax You can use page- prefix for page templates. Before 3.4 this was the only way to name page templates. Now you don't have to use this naming convention for page templates, although the page- prefix is still totally valid – Pieter Goosen Apr 14 '15 at 4:31
  • Just be sure you have at least one template page on your theme. Otherwise it woun't appear the input selector of templates. – gtamborero Aug 2 '18 at 20:59
8

Maybe this will help.

<?php 
/*
Template Name: Featured
*/
get_header(); ?>

Regular code here...

<?php get_footer(); ?>

If one theme works you could try replacing the files in the broken theme and test which file or files are broken. But first save the old files in a separate folder as a backup. Then you would know which file or files are broken pretty quickly.

| improve this answer | |
  • Yeah, sorry, I left that out for the sake of brevity, but it's in there. I'll edit my question. – Thomas Martin Apr 13 '15 at 20:02
  • This is an example of a working page: – a4jp.com Apr 13 '15 at 20:05
  • 1
    Okay. Maybe the theme is broken. Does your template file work in 2014 or 2015? – a4jp.com Apr 13 '15 at 20:11
  • Hey. Why did I get a minus 1 again. This was useful until Thomas edited his question. I added the code he was missing in his question. I think this is completely unfair. – a4jp.com Apr 13 '15 at 21:05
  • If I could vote you back up, I would. I don't have the reputation yet. – Thomas Martin Apr 13 '15 at 23:11
2

If you're not seeing the dropdown at all you might need to reload your theme. Try switching to another theme and then switching back.

| improve this answer | |
  • Thanks, yes, I tried that. The drop down is in the other theme, but not in my custom theme. I'll edit my question to include that. – Thomas Martin Apr 13 '15 at 20:06
2

By default Wordpress theme directory have not any template page then template page dropdown is invisible so follow the below instruction.

For display template page dropdown in wordpress admin page you need to create one template page in your theme directory code is below

<?php 
/*
Template Name: template home 
*/
?>

By creating this template file in your theme directory you can see template dropdonw is visible in admin page.

| improve this answer | |
1

I had this same issue today, not sure if its relevant but for me the fix was, go to the edit page section, expand screen options, page attributes was not ticked, ticked it and the template dropdown came back.

| improve this answer | |
0

This has happened two times for me. At the first time I changed the encoding of the file (header.php I think) to UTF-8 without BOM and all templates disappeared. Changed it back to regular utf-8.

At the second time I somehow edited/renamed the index.php (/themes/theme_name/index.php). Just had to create an empty index.php and now everything seems to be ok.

I hope this helps someone else. [WP 4.4.2]

| improve this answer | |

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