#6741 closed defect (bug) (worksforme)
in_category not working in WP 2.5 - ignores category id/name
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Template | Keywords: | |
Focuses: | Cc: |
Description
Used the following code as suggested in the Codex for in_category, however, in all cases regardless of the actual category ID that the post has assigned to it, the second include-file is being served.
`<?php
$post = $wp_query->post;
if (in_category(16)) {
include(TEMPLATEPATH . '/single-cat-16.php');
}
else {
include(TEMPLATEPATH . '/singleproduct.php');
}
?>`
Change History (3)
#2
in reply to:
↑ 1
@
17 years ago
Replying to Otto42:
Tested and that does work if you add global $post to the front of it, to ensure you're modifying the right $post variable.
The codex probably needs to be clarified on this point.
Can you please clarify "add global $post to the front of it" - perhaps an example? The Codex is not changed yet and until it is I need to know how to make this "workforme".....thx
Tested and that does work if you add global $post to the front of it, to ensure you're modifying the right $post variable.
The codex probably needs to be clarified on this point.