Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created a custom folder ("/templates") and I put all of my template files in the folder. instead of root ("/wp-content/themes/my-theme/"). It works fine.

Do I have to add some function for indicating "/templates/" folder as my templates folder? Usually you put them on root, right?

It works fine now but I just wonder if there is anything I have to. I can't find any information on wordpress codex. I just installed WPML and All of templates pages are 404 now. I wonder if it(custom template folder location) causes this 404 pages. cuz woo-commerce pages are showing fine. wc is not in my template folder. it generated by plugin.

-------- Additional

I created a template www/wp-content/themes/my-theme/tpl-home.php

I named this file as a template page.

<?php
/*
Template Name: Home
*/
get_header(); ?>

And I moved templates files on www/wp-content/themes/my-theme/templates/tpl-home.php

It still works well. I have seen a lot of themes do like this.

Do I need to setup some function to indicated the folder?

share|improve this question
    
have totally no idea what are you talking about. wordpress doesn't have templates, especially not ones that should be in your root directory. please provide more details. –  Mark Kaplun Nov 1 '13 at 8:37
    
what you mean by root? root of what? themes=>your-theme your currently active theme root? –  Rahil Wazir Nov 1 '13 at 8:52
    
Thanks guys. I added more information. please let me know if you need more. Root means. theme root.. so /wp-content/themes/my-theme/ –  pulla Nov 1 '13 at 9:01
    
Are you referring to WordPress Template Hierarchy template files, or custom page templates? –  Chip Bennett Nov 1 '13 at 12:53
    
Sorry, why? What does this accomplish that the Core functions and methods can not? –  s_ha_dum Nov 1 '13 at 14:55
add comment

1 Answer

You can place your templates within your active theme where ever you want but you have to include your files to functions.php.

You can make a folder called page-templates within your current theme.

/wp-content/themes/my-theme/page-templates

and add your custom templates there.

Include files in functions.php

if ( is_page_template( 'page-templates/my-template.php' ) ) {
    include_once 'page-templates/my-template.php';
}

it should work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.