Use different single.php file based on condition

In a previous edit you used:

if (in_category('21')) {
    include (TEMPLATEPATH . '/single-21.php');
} else {
    include (TEMPLATEPATH . '/single-29.php');
}

This is part of your solution, but before I continue, some important notes:

  • Don’t use include like that, instead get_template_part('single-21'); works better
  • Indent correctly
  • This clashes with how IDs work in the template heirarchy. E.g. a post with ID 21 will always use single-21.php as its template

For your contest problem, what you want is:

if ( post has the tag 'contest' ) {
    get_template_part();
}

To determine if the post has the tag ‘contest’ use:

$terms = get_the_terms( get_the_ID(), 'tag' );
$is_contest = false;
foreach ( $terms as &$term ) {
    if ( $term->name == 'contest' ) {
        // Yes, this post has the contest tag
        $is_contest = true;
        break;
    }
}

I’d recommend you read up on these:

  • register_post_type
  • register_taxonomy
  • get_template_part

I’d also strongly advise against hardcoding tags categories and numbers in your code, and that you get an editor that auto-indents your code, e.g. Sublime Text, PHPStorm, Netbeans, Komodo Edit, etc

Also as a last note, I strongly urge you not to use the query_posts function. Instead use WP_Query.