WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Showing thumbnails based on category (2 posts)

  1. Matt Hancock
    Member
    Posted 4 years ago #

    At the moment, I'm using this code to pull the thumbnail from the post and show it in an unordered list:

    <ul>
    	<?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    		<li>
    			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    			<?php the_post_thumbnail( array(150,150) ); ?>
    			</a>
    		</li>
    
    	<?php endwhile; ?>
    
    	<?php endif; ?>
    	</ul>

    I want to tweak it so that it'll pull the thumbnails from posts inside a specific category. I would like it also to be able to drop another loop below to show thumbnails from another category.

    Can anyone help?

  2. Matt Hancock
    Member
    Posted 4 years ago #

    Solved it myself. Here's the code for anyone who is interested:

    <ul class="thumbnail">
    <?php $wordpress = new WP_Query(); ?>
    <?php $wordpress->query('cat=3'); ?>
    <?php while($wordpress->have_posts()) : $wordpress->the_post(); ?>
    
    		<li>
    			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    			<?php the_post_thumbnail( array(320,240) ); ?>
    			</a>
    		</li>
    
    	<?php endwhile; ?>
    
    	</ul>

Topic Closed

This topic has been closed to new replies.

About this Topic