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()?
- Get post ids from WP_Query?
- order by numeric value for meta value
- Some doubts about how the main query and the custom query works in this custom theme?
- Pagination with custom SQL query
- How to query for most viewed posts and show top 5
- Is it possible to wrap Geo Location search around WP_Query?
- WP_Query displaying ALL posts
- WordPress Custom Query to show posts from last x years
- Perform query with meta_value date
- get_the_title($postID) OR get_the_title()?
- SQL Statement generated by WP_Query not producing expected results
- How do I create my own nested meta_query using posts_where / posts_join?
- Best practice for multiple queries on page
- Recommended way to drop a pending query (in pre_get_posts)?
- 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?
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- How to find out what “Blog pages show at most” is set to [duplicate]
- Best approach to create Hot and Trending sections
- Retrieve or Query Pages by ID
- SQL User Query by Multiple Roles using PHP
- Order posts by meta value and Date
- How to make orderby ‘meta_value_num’ OPTIONAL?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Multiple instances of Featured Image Query
- How do you Query posts with nothing in common?
- Get meta info related to current post
- Custom category search box for WordPress
- Sort users by “birthday” using WP_User_Query
- Query with a meta value inside a given range
- exclude posts with a specific custom field and value
- Store sticky post’s ids in a transient
- How to make Meta Query case sensitive?
- Performance when getting post meta for post retrieved by meta value
- Get attachment by meta_key value
- is there a way to show the the post title after the image?
- Bypass “supress_filters” in WP Query
- WP Query related posts by tags
- Order by summing multiple values
- How to display an other custom post type in a different custom post type’s archive?
- get_post_meta in WP_Query
- Exclude All Posts Which Do Not Have A Tag Assigned
- Getting additional columns from sql
- WordPress query posts with multiple post_meta data
- Easy way to write complex queries in wordpress
- Conditional operator OR not working with custom fields
- complex get_posts() query to select child pages
- How do I check if an article is popular this week?
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- Posts query according to meta box date
- Display post meta conditionally based on it’s value
- Sort by custom field that is an array?
- Max Posts and Memory Limit
- Randomly select one of last 3 posts
- WP_Query meta compare must include ALL array values
- How to query for a page, get data, then query for child pages of that page
- Query post and sort by custom value calculated with custom field on cpt
- Filter products on category AND tag
- Query post ordered by meta value that show first post that contained a tag
- Passing a SQL query to the WP Query
- wp query to use both author id and meta_query
- WP_Query() not working as expected
- Sort by price wpdb
- Trouble with serialized metadata
- pre_user_query vs pre_get_posts
- Custom filter from post meta
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- Problem with my loops
- My entry results are not consistently alphabetized
- I can’t get post based on its postmeta value and key
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- Saving custom fields for WP_Query to retrieve
- How to show all the associated posts with specific date of data metabox?
- Modify query to exclude certain ids and certain parents and its corresponding children
- How to order by datediff in WP loop?
- Find by post_meta, then sort by post_meta, then sort by date (wp_posts)
- WP_Query Posts by Metadata from Option Tree
- WordPress custom post type
- Custom Search Query – include only custom fields and title
- How to count post meta key values for all posts in database
- WP_Query with several meta_query-statements and order by meta_value
- Exclude categories and subcategories in QueryLoop
- wpdb LIKE request shows all database data
- Query posts by meta value and sort by another meta key
- Incorrect posts displayed on category page