Something that really interesting in WordPress is Custom Page Templates. With custom page templates we can create unique WordPress Blog much easier. Now we will share many common use to include template files in WordPress.
Inserting Using PHP Style
This is standard code using PHP include
include(TEMPLATEPATH . 'template-name.php');
Load Template
This is part of WordPress System we can use load_template(); this code will run without check the original files and will be auto executed
load_template(TEMPLATEPATH . '/template-name.php');
Locate Template Method
This is much better method than load_template(), this method will check the files available or not
locate_template($template_names, $load);
Why this method much better, because on this method we can added some parameter too
Get Query Template
With get_query_template() you can get themplate without write complete name. You can only write the name of the files
include(get_query_template('template-name'));
You can also get / call WordPress standard theme files such as 404, tag, category, search with this code get_*_template() change * with the theme name, example
include(get_404_template());
// will give the same result
include(get_query_template('404'));
Get Template Part
And this is fresh function on WordPress 3.0 this function called get_template_part(); use this code like this example
get_template_part($slug, $name);
More details about this functions, This function will include file named “{slug}-{name}.php”. The $name is optional, and if it’s empty, the function will include file named “{slug}.php”. You can see this is the way Gamelan WordPress Theme uses for including loop:
get_template_part('loop'); // general loop, file 'loop.php'
get_template_part('loop', 'index'); // loop for index, file 'loop-index.php'
get_template_part('loop', 'single'); // loop for single post, file 'loop-single.php'
That’s it, now you can choose which one that prefer and suitable for your WordPress Project, now include template files in WordPress much easier right? Thanks for Deluxe Blog Tips for share this tips
Pictures source Egotastic




This post has been an eye opener; I’ll add it to my
Can you help me out? I’m looking for ways to make a template for WP older posts. It goes like /page/2, page/3 etc… How to make a custom template for that?
thx
You can use if statement, example
< ?php if($paged==2) : ?>< div class="page2">
The Content
< ?php endif; ?>
Thanx, this is great.
I’ll check that out. I’m not PHP guy at all, but this should help me modify the template the way I want.