Guess you could use includes…
Or look at the idea of a child theme–Theme_Frameworks.
Thread Starter
stacef
(@stacef)
Could you elaborate on the use of includes? From the bit I know about them, that might be the way to go, but I’m not quite sure where to place them.
Currently, I’m calling my sidebars from the footer like this:
if (is_page('Archives')) { include(TEMPLATEPATH . '/sidebararchive.php');}
My single page calls are actually in “single.php”:
if ($variable == ('Yadayada')) {
include 'singlenews.php';}
So I figure I could add the directory path to the call but, with the page templates, they’re not seen in the page admin tool unless they’re in the same directory as all the other templates.
Also, in a larger sense, I wonder if this is the way to go or just a goofy kludge?
Thanks,
Stace
Could you elaborate on the use of includes?
You’ve explained it in your examples…
So I figure I could add the directory path to the call but, with the page templates,
I should have mentioned that I don’t think you will get there (using subdirectories) with Page Template if you use the Template field when writing a Page.
Also, in a larger sense, I wonder if this is the way to go or just a goofy kludge?
Goofy no, but kludgey, maybe 😉
Just as a reminder, you can use these:
get_header('myheader')
will include header-myheader.php
get_footer('myfooter')
will include footer-myfooter.php
get_sidebar('mysidebar')
will include sidebar-mysidebar.php
Of course those conventions don’t allow subdirectories.
Thread Starter
stacef
(@stacef)
Thanks for the check and the suggestions.
You mention …
I should have mentioned that I don’t think you will get there (using subdirectories) with Page Template if you use the Template field when writing a Page.
Is there another way to write a page other than using the admin panel? Kind of sounds like maybe there is …
Thanks again,
Stace
Well there is probably a plugin that will allow you to write a page outside of the admin, but I was just saying if you are going to use Page Templates that get assigned when writing a Page, don’t think you will be able to have a subdirectory to store those templates.
Thread Starter
stacef
(@stacef)
Gotcha.
How about this: somewhere there is code that tells WP to look in /wp-content/themes/[yourtheme]/ for page templates. Seems like it would be fairly simple to change it to /wp-content/themes/[yourtheme]/pages/. But I don’t know where that code is – any ideas?
Since that’s such a pervasive thing
Seems like it would be fairly simple to change it to /wp-content/themes/[yourtheme]/pages/
Doesn’t seem that simple…looks like it gets the page template information using ‘get_page_templates’ that in depends on values from get_themes
.
Maybe a plugin you might consider:
http://wordpress.org/extend/plugins/page-template-extended/
Thread Starter
stacef
(@stacef)
Thanks – I can’t even find the get_page_templates to get_themes path you mentioned. Can you tell me where you found the get_page_templates code that calls to get_themes?
And the plugin looks interesting but seems to work on the hierarchal page structure within WP rather than the hierarchal directory structure of the server.
Thanks for all your time on this.
Use something like http://wingrep.com and search for get_page_templates and get_themes
get_page_templates is in wp-admin/includes/theme.php
get_themes is in wp-includes/theme.php
Thread Starter
stacef
(@stacef)
Good call on the grep app … I had been opening each file individually and doing a text search. Worked ok with limited files in the theme directory but not so much with the wp files.
Thanks again for the pointers!
Thread Starter
stacef
(@stacef)
Solved my own problem: I used the “page.php” as a redirect.
I created a directory called “pages,” into which I put all my page template files (ie: newspage.php). I duped the page.php file, renamed it defaultpage.php and put it in the new pages directory. I kept the original page.php in the same location with the same name but replace the entire contents with conditionals like this:
<?php
if (is_page('629')) { include(TEMPLATEPATH . '/pages/homepage.php');}
elseif (is_page('186')) { include(TEMPLATEPATH . '/pages/generalpage.php');}
else { include(TEMPLATEPATH . '/pages/defaultpage.php');
} ?>
The last piece is through the WP admin panel>pages. Change the template to “default.” I found that this had already been done; when I moved the page templates to a subdirectory, WP no longer “saw” them and reverted to the default template.
The default template goes to page.php which now redirects to my subdirectory.
May seem like a lot of work but with 17 page templates, it helps keep things in order. Also did a variation on this for single.php.