is_category() and in_category() not working
-
Hello,
Having some problems with what seems like a simple conditional statement.
On single.php pages, I’m trying to call in different versions of the loop based on what category I’m in.
I’ve tried this:
`<?php
if (is_category(7) ) {
include (TEMPLATEPATH . ‘/wp-loop2.php’);
} else {
include (TEMPLATEPATH . ‘wp-loop.php’);
}
?>`Which kicks back a page with no results.
I’ve also tried this:
`<?php
if (is_category(7) ) {
include ‘wp-loop2.php’;
} else {
include ‘wp-loop.php’;
}
?>`Which works, but always returns wp-loop.php, regardless of whether or not I’m in category 7.
Finally, I’ve also tried this, which is the new and correct way to do what I’m trying to do, according to the wordpress codex:
`<?php
if (in_category(7) ) {
include ‘wp-loop2.php’;
} else {
include ‘wp-loop.php’;
}
?>`Oddly, this bit of code just breaks my page. The wrap of the page is still there, but the content well is empty.
I’ve also tried substituting the category number with the category slug, all with similar results.
Any help is much appreciated.
- The topic ‘is_category() and in_category() not working’ is closed to new replies.