could anybody help me with this question? “How to give posts on the mainpage a different layout depending on category they are in?” For example: display the posts which are in a specific category with specific background color, title color or icon (image) included in the post.
I have tried some things, but those damaged the page 🙁 .
Part of the code of my index file is below.
Thanks very much in advance.
<?php get_header(); ?> <div id="content" class="narrowcolumn"> <br> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <!-- This is the image I would like to change depending on the category the post is in. --> <img src="images/a.jpg" width="30" height="30" alt="hs" align="left" class="imgcat3"/> <a href="<?php the_permalink() ?>" class="title" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br> <small><?php the_time('F jS, Y') ?>, <!-- by <?php the_author() ?> --> filed under <?php the_category(', ') ?></small> <div class="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> <p class="postmetadata"><!--Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> --><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> </div> <address></address> <?php endwhile; ?>
- The topic ‘How to give posts on mainpage different layout depending on category?’ is closed to new replies.