• When I create or edit a Page, on the side menu of options such as Discussion, Page Status, etc., I cannot modify the Page Template. It does not even appear as an option. I looked at the code for edit-page-form.php to see if perhaps something needed to be modified.

    If I removed or modified:
    <?php if ( 0 != count( get_page_templates() ) ) { ?>
    then the Page Template option would appear, along with the dropdown menu.

    However, the dropdown menu only had ‘Default Template’ as an option. I had created a custom template and uploaded into the folder for the theme I am using. In case that was the wrong place to put the custom template, I tried other places in the hierarchy but it never appeared in the Page Template dropdown menu. (I assumed that would be the case since I had to modify the code in order for the option to appear.)

    I do not know why the Page Template option does not appear when creating/editing Pages. What am I doing wrong? Any help appreciated.

Viewing 11 replies - 1 through 11 (of 11 total)
  • did you mark your new template as such so WordPress would recognize it? You have to add a php comment in your template.

    e.g.:

    <?php
    /*
    Template Name: Page_no_sidebar
    */
    ?>

    Thread Starter kalavinka

    (@kalavinka)

    Yes, I included the comment for the template name. Is there anything else I need to do for it to be recognized so it appears in the Page Template dropdown menu?

    I guess I’m just puzzled as to why the Page Template info does not appear unless I modify edit-page-form.php. I don’t like messing with the files in wp-admin unless I’m absolutely positive that it’s necessary.

    You need both the default page.php AND another Page template to be present in your theme folder for the dropdown to appear.

    Thread Starter kalavinka

    (@kalavinka)

    Yes, I have had both the page.php and the custom template in the theme folder.

    I just refreshed the admin page and it finally showed up! I guess it just took awhile to recognize all the files in the theme folder? Anyway, I’m happy that now my mucking about with the theme can continue and I appreciate the feedback.

    You need both the default page.php AND another Page template to be present in your theme folder for the dropdown to appear.

    Why is that? I’m just curious because I run into this frequently and it’s a pain to create a page.php template I don’t need just to use a custom page template.

    Themes don’t technically need anything but index.php in them, so the only time page functionality in a theme is enabled, is when you physically have a page.php template file.

    It’s like a switch that tells wordpress “its OK to treat pages like pages now”

    Once that switch is enabled, all the other funky page stuff follows, like the ability to set custom templates.

    Huh. Interesting. Still… it would make sense for pages to already be treated as pages anyway. I appreciate you clearing that up for me.

    I guess the question is how? – where do you send pages unless there’s a page.php?

    WordPress is basically exercising some error-handling, becuase pages can easily exist without having a custom template applied. What to do with them?

    I’m sure you can be trusted to give all your pages custom templates, but can everyone else? – where to send the pages that don’t have custom templates?

    so, basically wordpress ensures that you must have a default fallback state, before allowing you to customise pages… it’s actually a pretty good idea that reduces the possibility of php errors through user accident.

    oh… and … happy to be of service.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    … I can’t find code anywhere that backs up this assertion that a page.php file must exist for Page Templates to work. If page.php does not exist, then the fallback would normally be to index.php.

    Frankly, if this is true then I’d consider it a bug, but I also can’t find where that “switch” gets flipped. Any clues?

    This comes from observed behaviour, not code trawling.

    “If page.php does not exist, then the fallback would normally be to index.php”

    Thats what I said.

    ..however, it doesn’t seem possible to make use of page templates without page.php… indicating that wordpress checks for page.php before allowing the use of templates.

    that’s a kind of “switch” which turns on pages, as well as associated page-based functionality, like custom templates.

    You can check that your theme is actually selected.

    I uploaded a new theme and simply overwrote the files that were there, WordPress was using the theme, but if i went to the Theme selection screen, none was selected.

    So check if its actually selected, my Custom template drop down menu returned when i did this.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Page Template option absent from Admin page for Pages’ is closed to new replies.