As mentioned in the comments you an issue in your meta query, as you set the key to 20161126
or similar. Instead key
should be filled with your meta key post_end_date
. Meta query also support multiple arrays to combine your query to also include posts where the meta key is not set. The example would be something like the following:
function expiry_filter($query) {
if( !is_admin() && $query->is_main_query() ) {
$expire = get_field('post_end_date') ? : date('Ymd');
$query->set( 'meta_query', [
'relation' => 'OR',
[
'key' => 'post_end_date',
'value' => $expire,
'compare' => '>=',
'type' => 'NUMERIC',
],
[
'key' => 'post_end_date',
'compare' => 'NOT EXISTS',
],
]);
}
}
add_action( 'pre_get_posts', 'expiry_filter' );
Related Posts:
- Using meta_query and custom fields within pre_get_posts to return posts within a numerical range
- Comparing arrays with meta_query in pre_get_posts
- Multiple orderby date arguments
- Filtering multiple custom fields with WP REST API 2
- WP REST API: Order posts by meta value (acf)?
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Query between dates using Date Picker fields
- Check for the existence of custom field
- ACF repeater field with meta_query
- sort by date in Advanced Custom Field
- Get specific repeater row (via advanced custom fields) based on Meta Query with Wildcards [closed]
- Query between dates using date picker filter breaks in WordPress 4.2.1
- WP_Query meta_query >= date
- Using pre_get_posts for meta value of LIKE comparison on ACF repeater sub field
- Advanced custom fields: Customise date picker’s start date (need to choose year 1500 onwards) [closed]
- Display post in order of ACF checkbox?
- Update post meta value as date difference between two fields
- How to break a date from ACF?
- WordPress Date with ACF
- Filter posts by advanced custom field
- Get posts with multiple meta values
- Get users based on month ACF datepicker field
- How can you query posts by advance custom field when the value is a serialized array? [closed]
- Using WP meta query to show custom post types by a start and finish date
- Query by radio button ACF
- pre_get_posts hook not targeting search results page query
- WP get_posts meta_query using ACF repeater field
- get_posts filter meta_query using ACF Checkbox
- Display posts every specific day
- Comparing two dates (ACF and current time)
- How to use germ_terms() with meta_query for ACF Taxonomy field?
- Convert number to date format within an array
- Pre get posts sort by meta key returns no results if meta key does not exist
- Array sorting by custom field date
- Display “Today” Instead of Date for Pubslished Posts
- Time sort with meta_key using UNIX timestamp failing due to date differences
- Front end form to create a custom post with preview
- Generate a excerpt from an ACF-wysiwyg-field
- Pods cms and “advanced custom fields” plugin
- Best practice – Meta Query vs. post_clauses for “left join” ordering
- Is there a way to do multiple ordering on a multiple meta_query?
- Vimeo thumbnails [closed]
- Is there a way to export Advanced Custom Fields data?
- Advanced Custom Fields plugin : displaying a YouTube video
- pre_get_posts and search query for admin
- Use meta_query to display events by date in custom field
- How to show recent and upcoming birthdays using meta_query
- Custom column sorting in WordPress admin post table
- How to add custom fields in rss feed
- If two first numbers exist in wp_meta_query value
- Query posts with numeric meta values within a given range
- Meta query for custom post type ignored in main query
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- ACF Update_field() update the field but changes are not seen in backend or rest api
- How to decrease the number of queries with get_posts and ACF?
- How to make Advanced Forms (and/or ACF) encode input value?
- How to Bind one post object Type with other postobject Type in Advanced Custom field [closed]
- ACF Wysiwyg Editor Image srcset for responsive images [closed]
- Exclude posts from main loop based on meta value
- User meta not saving properly
- Filtering from advance custom field data
- WP_Query with meta_query dosen’t return results
- Is there a better way of retrieving the name of an acf pagelink type from current post?
- Seemingly Simple Conditional Won’t Work?
- Prepared statements used incorrectly in ACF?
- Hide ACF from source code until a “show” button is clicked
- Pull info from Soundcloud embed into a custom field?
- How to disable field on Advanced Custom Fields? [closed]
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- Can you make a custom gutenberg block that allows the gutenberg editor within it?
- ACF Maps admin error: “For development purposes only” even after supplying api key
- ACF google map not working [closed]
- Help using acf/save_post hook to connect to Untappd API and update_field [closed]
- Get ACF fields in relationships of returned post
- Random images with no duplicates (ACF Gallery) [closed]
- Show single posts date, in a page of posts
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- ACF: If field contain a specific value, update value in another field
- Equation input with preview in classic editor
- Can’t get the frontend cache to be deleted manually
- meta_query is overriding default search
- Advanced Custom Fields | Help me link to a variable
- ACF Flexible Content with Bootstrap Carousel Repeater
- advanced custom fields if field has value show main div [closed]
- wp_split_shared_term_batch messing up upgraded ACF 5 data
- Populate ACF repeater with current structure of pages
- save_post affect creation and deletion
- How can I modify standard search query to include also ACF custom fields values?
- WordPress search form and search result through ACF field in custom taxonomy
- WP Meta Query – mixed AND / OR query doesn’t work
- display content in ascending order
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- How to second orderby in “pre_get_posts” by meta value or combine single date and time to timestamp
- ACF gives a syntaxError unexpected token
- Add image custom attribute [closed]
- Using ACF on Posts Page
- Advanced custom fields if else statement
- Advanced custom fields and post types
- Custom headings on WYSIWYGs per flexible content module in ACF
- Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)