Support » Fixing WordPress » Display differently the posts which are in certain category in recent posts

  • Hi

    I have a little problem with recent post listing. I think it should not be difficult but strangely I’m not capable of figuring it out.

    In my recent posts displaying column, I want to display the posts which are in certain category (category id: 237) differently. More specifically, in my recent posts listings, there are only the titles and their permalinks. But for the posts which are in the mentioned category, I also want to add the author name. But especially the ‘in category’ tag doesn’t accept ‘the_author’ code.

    Let me give you my recent posts listing codes:

    <div id="habermerk">
    <ul>
    <?php query_posts("order=DESC&showposts=30"); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <li>
    <a href="<?php the_permalink() ?>">
    <?php the_title(); ?></a>
    </li>
    <?php endwhile; ?>
    <?php endif; ?>
    </ul>
    </div>

    So in your opinion, how can I do it?

    Thanx a lot…

    Erhun

Viewing 1 replies (of 1 total)
  • Inside the loop:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    You could do something like this to find the category and then do something differently:

    <?php if ( in_category('237') ) { ?>
           <div class="post-cat-237">
    <?php } else { ?>
           <div class="post">
    <?php } ?>

    You should also check out this method if all you’re needing to do is style it differently. You can do the same sort of thing to give it a different class that you’re able to grab a hold of.

    http://lorelle.wordpress.com/2007/09/06/using-wordpress-categories-to-style-posts/

Viewing 1 replies (of 1 total)
  • The topic ‘Display differently the posts which are in certain category in recent posts’ is closed to new replies.