add class="$cat" to latest post list
-
Hey,
In de sidebar of our wp-site, I have a simple list of the latest posts. I would love to style it a bit by category. I thought it would be simple to add something like class=”$cat”, but I can’t seem to find a way to get the right value for $cat.
This is my code now:
<?php global $post; $tmp_post = $post; $args = array( 'numberposts' => 8 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>" class="<?php echo $cats; ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> <?php $post = $tmp_post; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘add class="$cat" to latest post list’ is closed to new replies.