Hi there.
In my single.php file, I have this code to call the contents of a post.
<?php get_template_part( 'includes/loop' , 'single'); ?>
Can I alter it to show different contents/templates based on the given TAGS for posts?
Say, I want to get the template loop-cat (includes/loop-cat.php) if post has 'cat' Tag. Same goes for the other template. Most propably I will have at least 10 templates to show. Plus, the default post or without Tag will use the default template.
I dont want to merge them in a single loop file because I am worried that the file may get heavy.
Please help me. If there are other better ways to call different templates for different tags, please let me know.
In my previous theme, things are different. I can call each template by replacing the single.php contents with this:
<?php
$post = $wp_query->post;
if (has_tag('dog')) {
include(TEMPLATEPATH.'/dog.php');
} elseif (has_tag('cat')) {
include(TEMPLATEPATH.'/cat.php');
} else {
include(TEMPLATEPATH.'/single-def.php');
}
?>
However, I find that it is not applicable to the Basic theme.
Thanks a lot.