Last active
July 14, 2022 03:38
-
-
Save ferourives/c96c470d5b46f7e33f1d71768eddf263 to your computer and use it in GitHub Desktop.
List Events by Year and Month Using ACF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $the_query = new WP_Query( array( | |
| 'post_type' => 'calender_item', | |
| 'post_status' => 'publish', | |
| 'meta_key' => 'calender_item_date', | |
| 'orderby' => 'meta_value' | |
| ) ); | |
| # This will hold what group we're in | |
| $current_header = ''; | |
| # The Loop | |
| while ( $the_query->have_posts() ) : | |
| $the_query->the_post(); | |
| # get the datum for this post | |
| $temp_date = get_post_meta( get_the_ID(), 'calender_item_date', true ); | |
| # If they aren't the same, we'll start a new group, which for now | |
| # just means setting a new heading | |
| if ( $temp_date != $current_header ) { | |
| $current_header = $temp_date; | |
| echo "<h2>$current_header</h2>"; | |
| } | |
| # ... do normal loop stuff here | |
| endwhile; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment