Well, you still have to order the posts by your date key, but as far as output, the general idea is to store the current month in a variable and check it against the date of each post, and only output it when it changes. A pseudo-code example:
$current_month="";
while( have_posts() ){
the_post();
$this_month = get_post_meta( get_the_ID(), 'your_date_key', true );
if( $this_month != $current_month ){
$current_month = $this_month;
echo '<h2>' . $current_month . '</h2>';
}
}
Related Posts:
- query posts in wordpress
- posts_nav_link(); not showing up on static pages
- Get list of months with posts
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- Custom URL parameters in template files
- Metadata Query when storing data as array possible?
- Keep sticky posts out of query unless they have featured image
- How to query the latest 5 posts and sort them by title?
- 2 loops, is_home won’t work, count is off
- How can I prevent posts with no title showing up in my query?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- CSS class on last post in loop ( custom query )
- Custom Post Type Query issue
- How to order by multiple date meta_values?
- How to create query to get top 3 sticky/latest posts
- WP_Query not getting all posts, just tagged posts
- tag__in does not return posts
- View list of all attachments on site
- multiple queries to get posts from same category?
- Best practice for implementing a blog page / section in wp_menu_nav()
- Paginated WP_Query doesn’t return 404’s, even when posts don’t exist
- issue displaying variations in custom template using WPeC 3.8.9.2
- how can I add an icon/image for a child theme?
- When to use add_action(‘init’) vs add_action(‘wp_enqueue_scripts’)
- How to change admin bar color scheme in MP6 / WP 3.8 front end?
- How to add Color Picker in Theme Options for the following?
- How to know if get_posts() failed?
- Theme Review: post thumbnail, header image, content width
- How to determine if a category is empty?
- The seventh parameter passed to add_submenu_page()
- How to enqueue scripts and styles only when there are needed?
- Unexpected width and srcset attributes for the_post_thumbnail();
- Pushing updates to your premium theme
- The best way to add stylesheets to WordPress
- WordPress custom post type page dysplay 404 error
- How wordpress handle upload images and how to use them in the code
- Change loop order via form or link (jquery, not URL)
- how to create theme based widget that can be drop in sider bar or footer
- CSS in child theme not overriding the parent theme [closed]
- How to test for MU via functions.php?
- List categories and exclude child categories
- Am I supposed to create a child theme for every theme I use?
- WordPress as a data intensive web app
- How to determine which custom header image is being shown
- Custom shortcodes not working using __s theme
- Disable wp_enqueue_style for theme on wp-admin
- Override theme programmatically
- How do I remove TinyMCE text format
- can’t understand _e function well
- Customizer: Unique identifier that distinguishes which image upload control is uploading an image
- Theme Splash Image within the “Appearance -> Themes” control panel [duplicate]
- Change content layout based on menu hierarchy
- Theme Loading Into Dashboard
- Disabling automatic teasers
- Can “Recent Posts” widget be filtered by functions.php?
- attachment.php code or tutorial
- How to filter or remove the “title” attribute from category links
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?
- Remove CPT slug from URL WordPress
- Custom get_the_excerpt() only works on first post
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- How can I add custom text styles to the visual text editor?
- Common single page template options
- how to remove the gallery shortcode in wordpress?
- What PNG Fix script do you recommend for IE6?
- How to show specific post meta?
- wpautop on section
- Are seven additional image sizes are too many?
- Show specific category posts on Genesis framework home page
- How do I use wp_nav_menu?
- how to get this tax_query working?
- How to add InnerBlock multiple times in the same block
- How to clean up the theme for production?
- Questions from a new WP Dev [closed]
- How to enable Disqus comments in a WordPress theme I’m creating from scratch? [closed]
- How to conditionally add a wp_filter
- HTTP Error when uploading images over specific dimensions
- PHP Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) on line 124
- how use ajax to custom page template
- Removing element from DOM with jquery through plugin Custom Scripts for Customizer
- hide theme files for admin beneath root
- How to load jQuery with Ajax in WP version 5.3.2?
- Loop is breaking my theme. How can I fix?
- How do you remove the “Your Main Benefit Statement Goes Here.” From one of my pages?
- Recall translations made with Poedit
- How to achieve this navigation style in wordpress navigation
- WordPress Ajax Spitting out a page as a response?
- Postname permalink page not found error
- After theme change the menus have to be manually linked to the corresponding theme location
- What’s the policy for building a theme that doesn’t support widgets/menus?
- Passing a location-dependent array via wp_localize_script within a shortcode
- What are these variables and where are they documented?
- Want to display page content after password prompt without page reload
- How to highlight current menu bar base on the URL?
- Why do some sites show themes/”themename” as the only theme?
- How can i move my product name & price from below thumbnail to be the rollover content in Avada & Woocommerce?
- How to send async emails in wordpress?
- ways to create customized theme (hard coded – no pagebuilder)
- Can’t select my block by clicking on it on apiVersion – but using blockProps
- Webpack does not create or update index.asset.php file in build folder