Monthly Archive in sidemenu
-
I have been trying to add a monthly archive to the side menu, but all I’ve managed to do is echo out a list of all the posts. This is what I have so far:
<?php $args = array( "post_type" => array("event"), "post_status" => "publish", "orderby" => "eo_the_start", "order" => "DESC", ); $month_query = new Wp_Query( $args );?> <?php wp_reset_query(); $posts = query_posts($query_string . $order); ?> <?php if( $month_query->have_posts() ) : ?> <?php while( $month_query->have_posts() ) : $month_query->the_post(); ?> <?php $current_month = date('F'); ?> <?php $event_month = eo_get_the_start( 'F'); if( $current_month != $event_month ){ echo '<ul><li><a href="'. site_url() .'/events/on/'.eo_get_the_start( 'Y/m').'"/>'. eo_get_the_start('F') .'</a></li></ul>'; //Print month $current_month = eo_get_the_start( 'F'); }?> <?php endwhile; ?> <?php endif; ?>
How do I list only the months prior to today’s date rather than every single post associated with a month?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Monthly Archive in sidemenu’ is closed to new replies.