Advertisement
Guest User

Untitled

a guest
May 17th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div class="accordionContent">
  2.     <ul class="sub-menu1"><?php
  3.         $y = date( 'Y' ); // The current year.
  4.        
  5.         while ( $y > 2000 ) { // Pick a reasonable year you want this loop to end at, to save your server some time.
  6.             $m = 12; // For December
  7.             while ( $m > 0 ) {
  8.                 $args = array(
  9.                     'posts_per_page' => -1,
  10.                     'cat'        => 7,
  11.                     'year'       => $y,
  12.                     'monthnum'   => $m
  13.                 );
  14.                
  15.                 $cat_q = new WP_Query( $args );
  16.                 if ( $cat_q->have_posts() ) {
  17.                     //echo $m; // This will only echo the month number, but you can figure out how to substitute it for the month's name, I'm sure.
  18.                     $p = 0;
  19.                     while ( $cat_q->have_posts() ) {
  20.                         $cat_q->the_post();
  21.                         $p++;
  22.                     }
  23.                     ?>
  24.                     <li>
  25.                         <a href="<?php bloginfo( 'url' ); ?>/YOUR-PAGE-SLUG/?month=<?php echo $m; ?>&year=<?php echo $y; ?>&cat=7"><?php echo $m.$y.'('.$p.')'; ?></a>
  26.                     </li>
  27.                     <?php  
  28.                 }
  29.                 wp_reset_query();
  30.                 $m--;
  31.             }
  32.             $y--;
  33.         }
  34.         ?>
  35.     </ul>
  36. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement