0

wp_get_archives('type=monthly')

I have a page called the previous newsletter that shows all the months in which i have posted the date. But i don't want to show the current month in the list of the Previous Newsletter. The current month's posts will be shown on the "current month newsletter" page.

1 Answers1

0

Assuming current month is the first item in a list you can hide it with jQuery.

Example code:

function test() {
// build the archive
   echo '<div class="months-list">';
   echo wp_get_archives('type=monthly');
   echo '</div>';
   ?>
   <script>
  (function($){
  $(document).ready(function(){
      // hide the first element of the list
      jQuery('.months-list li:first').hide();
      
  });
  })(jQuery);
  </script>
  
   <?php 
    
}

add_action('wp_head', 'test');
hhh
  • 394
  • 2
  • 15