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">
  3.         <?php
  4.         $y = date( 'Y' ); // The current year.
  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.                 $cat_q = new WP_Query( $args );
  15.                 if ( $cat_q->have_posts() ) {
  16.                     $p = 0;
  17.                     while ( $cat_q->have_posts() ) {
  18.                         $cat_q->the_post();
  19.                         $p++;              
  20.                     }
  21.                     $monthName = date( 'F', mktime( 0, 0, 0, $m, 10 ) );
  22.                     ?>
  23.                     <li>
  24.                         <a href="<?php bloginfo( 'url' ); ?>/YOUR-PAGE-SLUG?month=<?php echo $m; ?>&year=<?php echo $y; ?>&cat=7"><?php echo $monthName.' '.$y.'('.$p.')'; ?></a>
  25.                     </li>  
  26.                     <?php
  27.                 }
  28.                 wp_reset_query();
  29.                 $m--;
  30.             }
  31.             $y--;
  32.         }
  33.         ?>
  34.     </ul>
  35. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement