admin管理员组

文章数量:1125422

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

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.

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.

Share Improve this question edited Apr 14, 2015 at 12:59 Thomas Martin asked Apr 13, 2015 at 19:39 Thomas MartinThomas Martin 2392 gold badges3 silver badges11 bronze badges 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. – TheGentleman Commented Apr 13, 2015 at 20:11
  • It's name template-based.php – Thomas Martin 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 – Pieter Goosen 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
Add a comment  | 

6 Answers 6

Reset to default 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.

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.

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.

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]

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.

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"
    }
],

本文标签: Page editor missing Templates drop down