10

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.

4
  • 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. Commented Apr 13, 2015 at 20:11
  • It's name template-based.php Commented Apr 13, 2015 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 Commented Apr 14, 2015 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
    Commented Aug 2, 2018 at 20:59

6 Answers 6

9

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.

6
  • Yeah, sorry, I left that out for the sake of brevity, but it's in there. I'll edit my question. Commented Apr 13, 2015 at 20:02
  • This is an example of a working page:
    – a4jp.com
    Commented Apr 13, 2015 at 20:05
  • 1
    Okay. Maybe the theme is broken. Does your template file work in 2014 or 2015?
    – a4jp.com
    Commented Apr 13, 2015 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
    Commented Apr 13, 2015 at 21:05
  • If I could vote you back up, I would. I don't have the reputation yet. Commented Apr 13, 2015 at 23:11
4

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.

1
  • this one helped me after 2hrs of searching for an answer Commented Jan 29, 2021 at 8:09
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.

1
  • 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. Commented Apr 13, 2015 at 20:06
1

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]

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.

0
0

For the page template select/dropdown to appear in my custom theme (Block theme) I had to add the following in theme.json for each custom page template.

"customTemplates": [
    {
        "name": "home",
        "title": "Home"
    }
],

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