Show Category Title in get_posts loop
-
I’m using get_posts to create a link on my static homepage that directs people to the latest post from my latest trip. Instead of the post title, however, I’d like to show the category title below the post thumbnail.
I’ve tried single_cat_title and single_tag_title, but they don’t work inside a loop, from what I’ve gathered.
There’s got to be a simple PHP solution for this.
<li> <h2>Latest Trip</h2> <?php global $post; $myposts = get_posts('showposts=1'); foreach($myposts as $post) : setup_postdata($post); ?> <dl> <dt><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a></dt> <dd><a href="<?php the_permalink(); ?>">Grand Canyon</a></dd> </dl> <?php endforeach; ?> </li>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Show Category Title in get_posts loop’ is closed to new replies.