Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $posts = get_posts(array(
- 'posts_per_page' => 10,
- // 'cat' => '-1',
- 'order' => 'ASC',
- 'post_type' => 'post',
- 'orderby' => 'meta_value',
- 'meta_key' => '_expiration-date',
- 'paged' => get_query_var( 'paged' ),
- ));
- $group_posts = array();
- if( $posts ) {
- foreach( $posts as $post ) {
- $date = get_field('datum-concert', $post->ID, false);
- $date = new DateTime($date);
- $year = date_i18n('Y', strtotime( get_field('datum-concert', $post->ID, false) ) );
- $month = date_i18n('F', strtotime( get_field('datum-concert', $post->ID, false) ) );
- $group_posts[$year][$month][] = array($post, $date);
- }}
- foreach ($group_posts as $yearKey => $years) {
- foreach ($years as $monthKey => $months) {
- if ( is_user_logged_in() ) { ?> <div id="ads-leaderboard" class="ads"></div> <?php }
- echo '<h2 style="text-transform: capitalize; text-align: center;" id="';
- echo $monthKey.'-'.$yearKey;
- echo '">';
- echo $monthKey;
- echo ' ';
- echo $yearKey;
- echo '</h2>';
- foreach ($months as $postKey => $posts) { ?>
- <?php while ( have_posts() ) : the_post(); ?>
- <?php get_template_part( '/includes/content-templates/concert-single' ); ?>
- <?php endwhile;
- }}}
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement