Advertisement
deeve

sub-menu-accordion + month

May 17th, 2012
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  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.    
  7.     $m = 12; // For December
  8.     while ( $m > 0 ) {
  9.        
  10.         $args = array(
  11.             'posts_per_page' => -1,
  12.             'cat'        => 7,
  13.             'year'       => $y,
  14.             'monthnum'   => $m
  15.         );
  16.         $cat_q = new WP_Query( $args );
  17.         if ( $cat_q->have_posts() ) {
  18.             //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.
  19.             $p = 0;
  20.             while ( $cat_q->have_posts() ) {
  21.                 $cat_q->the_post();
  22.                 $p++;              
  23.             }
  24.             $monthNum = $m;
  25.             $monthName = date("F", mktime(0, 0, 0, $monthNum, 10));
  26.             echo '<li><a href="2956?month=';
  27.             echo $m;
  28.             echo '&year=';
  29.             echo $y;
  30.             echo '&cat=7">';
  31.             echo $monthName;
  32.             echo '&nbsp';
  33.             echo $y;
  34.             echo '(';
  35.             echo $p;
  36.             echo ')';  
  37.             echo '</a></li>';  
  38.             }
  39.         wp_reset_query();
  40.         $m--;
  41.     }
  42.     $y--;
  43. }
  44. ?>
  45.         </ul>
  46.         </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement