• I want to style the “recent posts” listing differently on my homepage (index.php) depending on which parent category they fall under. Can someone tell me how to do that? The only difference will be in the title of the post. It will have a different image and background color and text color. Everything else will be the same. So I need to know the code for that.

    Here is what I mean:

    If posts under parent category “Dogs”, then use div class “Dogs” for the title.
    If posts under parent category “Cats”, then use div class “Cats” for the title.

    Here is the current code I have, which doesn’t specify categories, can someone help me convert this to the above conditional calls? :

    <!-- BEGIN recent posts -->
    	<div class="cbox">
    	<?php
    	$wp_query = $tmp_query;
    	if (have_posts()) : $count = 0;
    	?>
    	<ul>
    	<?php while (have_posts()) : the_post(); $count++; ?>
    	<li<?php if ($count==1) echo ' class="first"'; ?>>
    		<div class="survivetitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    		<a class="attachment" href="<?php the_permalink(); ?>"><?php fs_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>
    		<p><?php echo fs_clean($post->post_excerpt, 300); ?>...</p>
    	</li>
    	<?php endwhile; ?>
    	</ul>
    	<?php else: ?>
    	<p><?php fs_lang("No articles."); ?></p>
    	<?php endif; ?>
    	</div>
    	<!-- END recent posts -->

    Plus, I want to make sure I can just specify a parent category and don’t have to specify each and every subcategory under the parent?? So can I just specify all posts under “Dogs” gets A styling and all posts under parent category “Cats” gets B styling, or do I need to list out each dog and cat subcategory, respectively?

    THANK YOU SO MUCH FOR ANY HELP!!!

  • The topic ‘Need conditional call for category posts’ is closed to new replies.