My first suspicion that something is amiss is this:
$post = $wp_query->post;
You shouldn’t need to do this. Anywhere that the query conditionals are already setup, the conditionals will assume the current Post ID. So, that suggests a couple things:
- The specified categories don’t actually exist. I will assume this not to be true, since you indicate that you use this same code successfully elsewhere in the Theme.
- You’re calling this code somewhere that the current query/post isn’t actually set. For example, you might be calling this code in the context of an archive index page, or a search page, etc. outside the Loop. The odd thing here is that your title indicates that you’re calling this code in
single.php.
Can you do two things:
- Post your entire
single.phpcode, so we can see the conditional code in context? - Try replacing
$post = $wp_query->post;withglobal $post;
Edit
What’s posted above is the entire single.php
What’s being returned by the $post object? What do you get on a var_dump( $post ); after you globalize it?
Also, probably not related to your problem (the query is set at wp, so query conditionals should be available at template_redirect, which is where single.php gets loaded), but I would suggest putting your get_header(), get_sidebar(), and get_footer() calls in single.php, and trim single-auto.php, etc. down to their actual content.