WordPress Logo

I’ve not spent a great deal of time looking at WordPress 3.4 since it’s release. However there is a nice little sneaky feature that seems to have been added and not advertised very much. If you, like me, work on large themes that require multiple page templates your theme can start looking really messy really quickly. Now thanks to some work in WordPress 3.4 you can place your page templates in a sub-directory.

You can name the directory anything and they still can be overridden by your child themes. The child theme will just need the same directory structure. This does only work 1 level down so wp-content/themes/mytheme/template-hello.php can now be wp-content/themes/mytheme/page-templates/template-hello.php.

There is only one big thing to watch out for! Moving your page templates into a sub-folder is essentially the same as renaming them so it will unassign that page template for all pages currently using it. So make sure you make a note of all your pages and their templates so you can dive in and fix them!

More information can be found in this handy blog article!

UPDATE: Friday 6th July

Just a little update after finding something extra out today.

When using conditional tags in your theme you need to declare the folder name. Previously you would just do:

if ( is_page_template( ' my-template.php' ) ) {

//Code here

}

Now you have to:

if( is_page_template( 'my-folder-name/my-template.php' ) ) {

//Code here

}

Leave a Reply

Mojowill Avatar

Who the Hell am I?

I'm Will, a full time web developer, geek and musician. I develop using PHP and MySQL and spend most of my time working with WordPress or CakePHP. When I'm not buried in code I'm gaming, cooking or writing and recording music in my studio. I like sci-fi, pancakes and coffee and am totally prepared for the zombie apocalypse...

Stalk me on these other sites...

Why not be super creepy and check me out on all these other sites, I think they call it social media?

%d bloggers like this: