Title: loop categories
Last modified: August 20, 2016

---

# loop categories

 *  Resolved [nachovidal](https://wordpress.org/support/users/nachovidal/)
 * (@nachovidal)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/loop-categories/)
 * Hi,
 * I’m building a template that displays all categories including the posts within
   these categories on the homepage (one big scroll page).
 * The posts need to be ordered by category. I’v tried a 1000 thing, but nothing
   seems works.
 * Can someone help me out please!

Viewing 1 replies (of 1 total)

 *  Thread Starter [nachovidal](https://wordpress.org/support/users/nachovidal/)
 * (@nachovidal)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/loop-categories/#post-2405476)
 * now i’m doing it like this, but i have to hardcode al the categories i want to
   show. I’m looking for a dynamic version! 🙂
 *     ```
       <div class="panel" id="cat-item-6">
               	<?php query_posts('category_name=catname&posts_per_page='); ?>
                  	<?php if ( count( get_the_category() ) ) : ?>
                   <h1 class="page-title"><?php $catid = $wp_query->query_vars['cat']; $cat_family = array_reverse(explode(',',get_category_parents($catid,false,','))); echo ($cat_family[2]) ? $cat_family[2].' ' : '';?><br/>
       					<span class="bigga">
       						<?php single_cat_title(); ?>
       					</span></h1>
       				<?php endif; ?>
       			<?php while (have_posts()) : the_post(); ?>
                   <?php get_template_part( 'content' ); ?>
       			<?php endwhile; // end of the loop. ?>
       			<?php rewind_posts();?>
                </div>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘loop categories’ is closed to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [category](https://wordpress.org/support/topic-tag/category/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [nachovidal](https://wordpress.org/support/users/nachovidal/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/loop-categories/#post-2405476)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
