Title: Different loop based on category name
Last modified: August 20, 2016

---

# Different loop based on category name

 *  [HappyCloud](https://wordpress.org/support/users/happycloud/)
 * (@happycloud)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/different-loop-based-on-category-name/)
 * I need to show a differnt custom loop depending on what category the current 
   page is filed under.
 * There are about 7 or 8 categories, each needing their own little loop.
 * Here is my current loop code
 *     ```
       <div class="offer rounded shadow">
       	<?php query_posts( 'post_type=offers&category_name=home-page&posts_per_page=1&orderby=rand'); ?>
   
       	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       		<span><a href="<?php the_permalink('');?>"><?php the_title('');?></a></span><?php the_content('');?>
       	<?php endwhile; ?>
       	<?php else : ?>
       	<?php endif; ?>
       	<?php wp_reset_query('');?>
       </div><!--/.offer-->
       ```
   
 * I need to be able to show a variation of this loop for each of the 7 or 8 categories.
 * Any help would be great.
 * Thanks in advance

The topic ‘Different loop based on category name’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [HappyCloud](https://wordpress.org/support/users/happycloud/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/different-loop-based-on-category-name/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
