Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2.  
  3. $posts = get_posts(array(
  4. 'posts_per_page' => 10,
  5. // 'cat' => '-1',
  6. 'order' => 'ASC',
  7. 'post_type' => 'post',
  8. 'orderby' => 'meta_value',
  9. 'meta_key' => '_expiration-date',
  10. 'paged' => get_query_var( 'paged' ),
  11. ));
  12.  
  13. $group_posts = array();
  14. if( $posts ) {
  15.  
  16. foreach( $posts as $post ) {
  17. $date = get_field('datum-concert', $post->ID, false);
  18.  
  19. $date = new DateTime($date);
  20. $year = date_i18n('Y', strtotime( get_field('datum-concert', $post->ID, false) ) );
  21. $month = date_i18n('F', strtotime( get_field('datum-concert', $post->ID, false) ) );
  22.  
  23. $group_posts[$year][$month][] = array($post, $date);
  24. }}
  25.  
  26. foreach ($group_posts as $yearKey => $years) {
  27. foreach ($years as $monthKey => $months) {
  28.  
  29. if ( is_user_logged_in() ) { ?> <div id="ads-leaderboard" class="ads"></div> <?php }
  30. echo '<h2 style="text-transform: capitalize; text-align: center;" id="';
  31. echo $monthKey.'-'.$yearKey;
  32. echo '">';
  33. echo $monthKey;
  34. echo ' ';
  35. echo $yearKey;
  36. echo '</h2>';
  37.  
  38. foreach ($months as $postKey => $posts) { ?>
  39. <?php while ( have_posts() ) : the_post(); ?>
  40. <?php get_template_part( '/includes/content-templates/concert-single' ); ?>
  41. <?php endwhile;
  42. }}}
  43.  
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement