You might try adding a second meta_query that would look for anything without the meta key:
$args = array(
'post_type' => 'agenda',
'paged' => $paged,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'datum_event',
'value' => date('Ymd'),
'compare' => '<='
),
array(
'key' => 'datum_event',
'meta_compare' => 'NOT_EXISTS',
'value' => 'placeholder'
),
),
);
Note that the value of placeholder is required to the make the not exists work – see https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
This is untested code but hopefully it helps!
Related Posts:
- Using OR conditions in meta_query for query_posts argument
- Query Custom Meta Value with Increment
- What is an efficient way to query based on post_meta?
- Select from wp_post and multiple meta_value from wp_postmeta
- Fetch Record based on meta key dates
- how to make members list directory through wordpress post custom meta key.
- How to increase load time of an archive/search page (WP_Query)
- How do i create a custom post query when the meta value is an array?
- I need query_posts() to order results first by a meta value and then by post ID
- How to search CPTs in draft using get_page_by_title()
- WP Query to order posts by multiple meta fields
- How to query post ids liked by the Author
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- WP_Query with “post_title LIKE ‘something%'”?
- How to only display posts whose meta_value field is not empty?
- Get post ids from WP_Query?
- Nested meta_query with multiple relation keys
- Can wp_query return posts meta in a single request?
- order by numeric value for meta value
- Some doubts about how the main query and the custom query works in this custom theme?
- Wp get all the sub pages of the parent using wp query
- How do I query for posts by partial meta key?
- Pagination with custom SQL query
- Use REGEXP in WP_Query meta_query key
- How to query for most viewed posts and show top 5
- WP Query where title begins with a specific letter
- WordPress retrieving meta data for all custom post types in list view
- WP_Query vs get_posts
- Order by optional meta key?
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Whats the difference between post_limits and pre_get_posts?
- Reduce or prevent calling of update_meta_cache
- Is there a way to extend WP_query so Custom Post Types can have properties?
- Query Posts in a Predefined Order
- Order posts by ID in the given order
- What is the most efficient way of querying posts based on visits and date for current day?
- Is it possible to wrap Geo Location search around WP_Query?
- Getting attachments by meta value
- Query Multiple Post types each with own meta query
- WP_Query displaying ALL posts
- Get posts by menu ID
- Get the number of posts from the current page results
- Is it possible to select against a post’s parent’s fields with WP_Query?
- WordPress Custom Query to show posts from last x years
- meta_query where value is equal to given value
- Extending WP_Query — Optimise SQL query
- WP-CLI How to generate a list of posts with corresponding meta values
- How to know which one is the main query?
- Get posts by meta data OR title
- How to filter sql only for a specific post type
- Perform query with meta_value date
- Using is_main_query to select custom post type on certain page
- WP_Query ordered by custom field that is a date string?
- get query’s query string
- Meta Query with date and time on the same Day before given time
- get_the_title($postID) OR get_the_title()?
- How to make an activities stream mixing posts and comments?
- Display Posts by modifying the where clause only for my query
- SQL Statement generated by WP_Query not producing expected results
- WP_Query not working as expected for attachments and custom meta_query
- SQL query equivalent to WP User Query
- How do I create my own nested meta_query using posts_where / posts_join?
- How to count post meta key values for all posts in database
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- Best practice for multiple queries on page
- Group posts by meta_key
- How should I use posts_where to change meta_value from a string to integer?
- Recommended way to drop a pending query (in pre_get_posts)?
- How to Get All Posts but the Private ones?
- How can I create a WP_Query that returns posts where one meta_value
- how to retrieve specific product attribute value in an sql query?
- WordPress altering my custom query, How to fix it?
- WP Meta Query for some meta (array) values
- WP Query post meta value
- Would this post meta be better added to the post table rather than post_meta table
- Custom URl parameter
- query posts in functions.php and update a field
- Compile meta values from custom loop into array and then calculate sum total
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- How to query ‘posts_per_page’ to display a different blog posts index template?
- how to fire join query with post_meta
- How to find out what “Blog pages show at most” is set to [duplicate]
- Best approach to create Hot and Trending sections
- WP_Query, custom sort and custom filter
- Multiple search queries on one page
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- Pass the same object to multiple widgets in a template with one query
- Filter WordPress posts by between parameter
- Retrieve or Query Pages by ID
- SQL User Query by Multiple Roles using PHP
- Advanced WP Query hogs the SQL server
- Order posts by meta value and Date
- SELECT * FROM $wpdb->posts WHERE ID > 160
- Efficient way to update multiple post meta
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- How do you query wordpress posts using a math formula between multiple meta field values?
- How add a custom posttype name using ACF field to a query post array
- How to make orderby ‘meta_value_num’ OPTIONAL?