Use is_category(); Usage here:
You can use either the category id or the category as a parameter. More info here:
http://codex.wordpress.org/Function_...ce/is_category
Also, if you want to include a file without calling an absolute URL, save it on your stylesheet directory and call it like this:
PHP Code:
<?php include(TEMPLATEPATH . '/file.php'); ?>
All in all:
PHP Code:
<?php if ( is_category('5') ) {
include(TEMPLATEPATH . '/topofpost5.php');
} ?>

Originally Posted by
junedodge
I'm trying to change the appearance of posts based on what category they are in. I was thinking of adding a conditional include statement to Single Post (single.php).
I can get a static include to show on all posts by putting it directly before where the content is called up.
For example (added the red to the file in between the existing lines)
<div class="entry">
<?php
include("http://XXX.org/topofpost.php");
?>
<?php the_content('<p>Read the rest of this entry »</p>'); ?>
But to get the conditional include to work, I need to know the variable for the category. And I can tell cat_ID isn't what I need...
if (cat_ID == '3') {
include("http://XXX.org/topofpost3.php");
}
if (cat_ID =='4") {
include("http://XXX.org/topofpost4.php");
}
In my installation I will only have one category for each post so there would not be a problem with having two categories...
TIA,
June
Bookmarks