Forums

Referencing a subdirectory in a custom page template? (4 posts)

  1. onethousandseas
    Member
    Posted 2 months ago #

    If I want to make extra custom templates for my theme, is it possible to put it in a subdirectory within the theme directory to reference it?

    So if the code at the top of a custom page were this:

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

    how would I reference that if I were to put snarfer.php inside a directory named "extra-templates"?

  2. apljdi
    Member
    Posted 2 months ago #

    You can easily put .php files in subdirectories and call them using get_bloginfo('template_url').'/subdirectory/somefile.php'. I don't know if WP will recognize a template file if you put it in a subdirectory. Have you tried that?

  3. onethousandseas
    Member
    Posted 2 months ago #

    Yep, I put it inside a subdir, but it didn't work when I simply tried to call it through the control panel.

  4. kvcrawford
    Member
    Posted 1 month ago #

    I wish it were possible to put custom page templates in a subdirectory, and still choose them in the "Template" <select> box from "Edit Pages" in the admin panel. It would keep the template's folder a lot cleaner when using a lot of custom page templates.

    It would also be nice if you could keep your stylesheet(s) in their own "./css/" directory.

Reply

You must log in to post.

About this Topic