WordPress.org

Ready to get started?Download WordPress

Forums

show post by year/sub-category (1 post)

  1. amnaachohan
    Member
    Posted 6 months ago #

    Hey

    I am making a category archive my file name is category-grants.php , grants is my main category slug .. i want to show posts like this

    Year
    Sub-cat1
    posts
    Sub-cat2
    posts
    Year
    Sub-cat1
    posts
    Sub-cat2
    posts
    and so on ..

    Can anyone please help in this ??
    here is my code

    <!-- GRANTS LIST -->
    <div class="eight columns mobile-four pull-four" style="padding-right:0;padding-left:15px;">
    <div class="grantsBoxesHeader">
    <h1><?php //echo get_category_parents( $cat, true, ' &nbsp; ' ); ?>Grants</h1>
    <?php echo category_description(); ?>
    </div>
    <div class="homeBoxContent grantBoxContent" style="padding-left:15px;">
    <?php
    $parentCatName = single_cat_title('',false);
    $parentCatID = get_cat_ID($parentCatName);
    $childCats = get_categories( 'child_of='.$parentCatID );
    if(is_array($childCats)):
    foreach($childCats as $child){ ?>
    <div class="grantListYear"><?php the_date('Y'); ?></div>
    <h2><?php echo $child->name; ?></h2>
    <?php query_posts('cat='.$child->term_id);				while(have_posts()): the_post(); $do_not_duplicate = $post->ID; ?>
    <!-- POST CODE -->
    <!-- 2013-->
    <!-- 2013 / EDUCATION -->
    <!-- ONE GRANT RESULT FOR 2013 / EDUCATION -->
    <div class="grantListEntry">
    <div class="grantListGrantee">
    <a href=""><?php the_field('grantee'); ?>
    </a>
    </div>
    <div class="grantListTitle">
    <a href="<?php the_permalink(); ?>">
    <?php the_title(); ?>
    </a>
    </div>
    </div>
    <!-- SEPARATION -->
    <div class="swp-hr" style="background:#fbfbfb;">&nbsp;</div>
    <!-- END POST CODE -->
    <?php
    endwhile;
    wp_reset_query();
    }
    endif;
    ?>
    </div>
    </div>
    <div class="homeBoxesHeadersBg hide-for-small">&nbsp;</div>
    </div>

    Please any suggestions :( ??

    Thank you in advance

Reply

You must log in to post.

About this Topic