This should get you started:
<?php
$the_query = new WP_Query( array(
'post_type' => 'kalender_item',
'post_status' => 'publish',
'meta_key' => 'kalender_item_datum',
'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(), 'kalender_item_datum', 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;
?>
Related Posts:
- Compare two numeric custom fields
- Advanced Custom Fields – Query Efficiency
- can’t get query to order posts by acf datepicker
- Order posts by custom field DATE value
- Get the_field of Advanced Custom Fields in a custom query [closed]
- Advanced Custom Fields – Relationship post foreach query
- Querying Advanced Custom Fields
- How can I get the name of term post meta value which equals term id
- Exclude in get_pages() based on meta field
- WordPress query: merge meta key (number) values and sort
- wp query multiple values > display a specific value first
- Advanced Custom Fields Query with Different Values of the Same Key
- Modify a query using both a text field and a true/false AFC field
- How to display SQL query that ran in query?
- How can I create a meta_query with an array as meta_field?
- Query multiple meta key values?
- How to Optimize WP site for millions of posts
- How to get comments by post ID?
- Differences between wpdb->get_results() and wpdb->query()
- Is there a way of increasing the speed of this query?
- Get all image from single page using this query
- How can I query all users who registered today?
- Get Terms by IDs with IDs order
- Reversing the order of posts AFTER the query is performed
- what are the numbers between curly brackets in search query
- simple sql query on wp_postmeta very slow
- Using WordPress public query variables
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- When/why does ‘$query->get( ‘tax_query’ );’ return empty?
- How to get link and title of next and previous post on single page
- Create pagination and order according to alphabet
- wpdb get posts by taxonomy SQL
- Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
- wordpress query – orderby child post date
- How many WordPress SQL Queries per page?
- How to display Section for certain time
- Add multiple value to a query variable in WordPress
- Search custom post type by meta data
- Custom query_var causes displaying posts archive on front page
- Slow wp_enqueue_media()
- Multipart/formatted MySQL query problem
- What is the most efficient way of implementing a favorite post system?
- Remove [gallery] shortcode altogether
- wp_dropdown_categories with multiple select
- Why does get_the_time(‘F j’) return November 30 for all posts?
- ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format
- Query by one meta_key and sort by another (possibly NULL value)
- How to tune search argument in WP_Query to show only exactly the same results?
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- Very slow query
- query multiple taxonomy and show post count
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- Query & Sort Comments by custom comment meta
- How to get my loop to pull posts into three columns
- How to display lastest post date in the homepage?
- Custom $wpdb Query for Custom Post Type by Category
- How to get the posts published in last two days using WP_Query?
- Get a user’s most recent post title
- Categories and products in random order
- add_query_arg() XSS Vulnerability
- Count user posts by user ID, Post type and Post status
- Can’t pass table to $wpdb->prepare
- Query set using tax_query with relation ‘OR’ modifies category object?
- $query->query_var[‘post_type’] not set for pages
- Query by 2 values of a repeater ACF field
- is_archive() doesn’t work on public query var archive pages?
- How to extract all ID variables from a query string?
- When add_query_arg() is necessary?
- Different Main Navigation per category
- How to get category link without a database query
- Insert html after certain amount of posts?
- wp remove query
- Show recent products first but “sold out last” in query
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- Filter query posts by the count of metas for a meta key
- How to tell if $query_var isset?
- Show All Posts Insert Edit Link
- $wpdb->get_var not returning a result
- search through post-type attachments titles
- How to count get_users query?
- Date query year and month OR just year
- cron job to auto delete posts of a specific post type older than x days
- Possible to get posts from multiple meta keys/values in a single query?
- Are database queries created using WordPress filters protected from SQL injection?
- Get IDs of posts currently visible on archive
- Get posts by category with pure SQL query
- Sorting Grids with Essential Grid and Events Manger
- $args numberposts variable
- The use of including upgrade.php when building custom queries
- get post id using the $query_vars variable
- Most effective use of DB querys
- Difference between fragment caching and wp_cache
- Custom query to get terms from post ids
- Save default value for empty or missing post meta
- Remove Unnecessary Mysql Query
- Get the timout value of a saved transient?
- Help with wordpress custom query and advanced custom fields plugin
- Grouping related postmeta data via SQL query