Recent Post Thumbnail with Categories
-
I recently created a new theme and learned how to insert a recent post thumbnail into a template page. It works fine, but I’m wondering if anyone knows how I can alter the code to only show posts from a particular category. This code is in the functions.php file and is as follows:
if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } //Adds thumbnails compatibility to the theme set_post_thumbnail_size( 300, 200); // Sets the Post Main Thumbnails add_image_size( 'recent-thumbnails', 375, 250); // Sets Recent Posts Thumbnails function recentPosts() { $rPosts = new WP_Query(); $rPosts->query('showposts=9'); while ($rPosts->have_posts()) : $rPosts->the_post(); ?> <li> <a href="<?php the_permalink();?>"><?php the_post_thumbnail('recent-thumbnails'); ?></a> </li> <?php endwhile; wp_reset_query(); }And in the template file the function is called with the following:
<?php echo recentPosts(); ?>Any help would be great!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Recent Post Thumbnail with Categories’ is closed to new replies.