Forums

[resolved] Monthly Archives, Grouped By Month (3 posts)

  1. brianbrey
    Member
    Posted 1 year ago #

    I am trying to figure out a way to get monthly archives and group them by category.

    Category 1
    August 11
    July 11
    June 11

    Category 2
    August 11
    July 11
    June 11

    Category 3
    August 11
    July 11
    June 11

    Brian

  2. brianbrey
    Member
    Posted 1 year ago #

    I found this code which essentially groups the posts by category... The more i look for what i'm trying to do, the more i think it can't be done.

    <?php
    $cat_args = array(
      'orderby' => 'name',
      'order' => 'ASC',
      'child_of' => 0
    );
    
    $categories =   get_categories($cat_args); 
    
    foreach($categories as $category) {
        echo '<dl>';
        echo '<dt> <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></dt>';
    
         $post_args = array(
          'numberposts' => 5,
          'category' => $category->term_id
        );
    
        $posts = get_posts($post_args);
    
    	foreach($posts as $post) {
    	?>
    		<dd><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dd>
    	<?php
    	}
    	echo '<dd class="view-all"> <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>View all posts in ' . $category->name.'</a></dd>';
    	echo '</dl>';
    }
    ?>
  3. brianbrey
    Member
    Posted 1 year ago #

    This plugin did the trick

    http://kwebble.com/blog/2007_08_15/archives_for_a_category

    Installed it and simple used " <?php wp_get_archives('cat=27,type=monthly'); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic