Template Parts in WP 3.0

Use template parts in WP 3.0 for repeated blocks of code. In the example below, you would create a file called loop-custom.php which would be called from each section.

//Do Layout stuff
//Query One
$query= 'cat=' . $catid. ''; query_posts($query);
//Get the Posts
get_template_part( 'loop', 'custom' );
wp_reset_query();

//Do Layout Stuff
//Query Two
$query= 'cat=' . $catid. ''; query_posts($query);
//Get the Posts
get_template_part( 'loop', 'custom' );
wp_reset_query();

//Do Layout Stuff
//Query Three
$query= 'cat=' . $catid. ''; query_posts($query);
//Get the Posts
get_template_part( 'loop', 'custom' );
wp_reset_query();

wp_reset_postdata();
//Get the Page comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*