Forums

[resolved] loop categories (2 posts)

  1. nachovidal
    Member
    Posted 6 months ago #

    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!

  2. nachovidal
    Member
    Posted 6 months ago #

    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>

Reply

You must log in to post.

About this Topic