SOLVED:
I had this in the function to save the meta data (like an idiot!!)
if ( !$value ) delete_post_meta( $post->ID, $key ); // Delete if blank
So it wasn’t saving the meta value if set to 0.
I changed it to:
if ( !$value ) add_post_meta( $post->ID, $key, '0' ); // add 0 if blank
Simple to solve… after hours of agony.
Related Posts:
- Using meta_query, how can i filter by a custom field and order by another one?
- Mixing regular and custom post types (with meta_query) on home page
- meta_query for keys that aren’t yet set
- Get posts based on meta key/value
- How to create a wp_query that contains both meta_query and tax_query
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Ordering posts having multiple post-meta date fields
- Querying custom post type with 2 custom fields (date-range)
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How Can I save multiple records in same meta key?
- Order Posts by Taxonomy and Meta Value
- filter search result with custom post type meta key
- order by meta_value serialized array
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Using Query Posts With Multiple Post Types And A Taxonomy
- Can’t sort order of wp_query with 2 meta keys
- Combine tax_query and meta_query in WP_Query
- query order by date on custom type: wrong order
- Used with meta_query in query_posts works slowly
- exclude custom post type by meta key in wp_query
- Display custom post types with custom date field value (before today) & order by custom date field
- Query for custom post type objects in a taxonomy and with a meta value
- Display custom post type taxonomy and month
- Meta_query with relation ‘OR’ killing server CPU
- Filtering by Post Meta Custom Fields – Performance
- Ignore sticky posts if post is not in meta query
- Is it possible to apply a meta_query to one specific post type in a query with multilple post types?
- Query that joins the postmeta table twice
- Pull a post based on a meta value in a custom post type
- Setting proper query for multiple custom admin filters
- WP_Query: include custom post type only with specific meta value
- Returning a list of custom post types excluding those without a specific meta_value
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- filter custom post type by meta key in dashboard
- Meta query for custom post type ignored in main query
- How to filter wp_list_categories output with some custom post type meta query?
- Display a CPT based on a metabox selection
- How to do WP_Query with two meta fields with orderby clause
- Meta Query Not Returning Output Despite Having Matching Values
- Why is this query not working? (Standard posts + custom post type)
- Using meta_query and tax_query at the same time
- search suggest – filter post type
- Meta Query posts not showing on ending date of custom field
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Ordering custom post type by multiple custom fields
- Possible to filter custom post type with multiple meta data?
- filter search custom field query
- WP_query – Filter by tax_query and meta_query using multiple select
- Is it possible to load a different sidebar in single.php based on a meta_query filter?
- Querying multiple values from a single key
- find custom post type post by searching its custom field with my string
- WP_Query of custom post type sorted by meta_key has unexpected results
- Query for post and costom post_type in same category filtered by meta for post_type
- fetch custom post by meta key if key value is does not know
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- WP_Meta_Query object with conditionals
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- order the meta query results by 2 custom fields
- Order admin post list table by meta field, and have posts without the meta field always be at the end of the list
- Using OR relation in meta_query to check for a value before sorting by another
- Filter result of Custom Post Type using meta_query with ACF
- build child and anchestor three from post parent
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Query posts by current ACF meta key value on single page as related posts
- meta query condition don’t work
- Custom query result empty on page 2
- Meta query and compare “!=” not working as expected
- meta_query Where the key value is stored as an array
- Use WP_query to match post types based on custom field values
- Show posts from WP Custom Post Type selected from a field in a metabox
- ACF meta_key and meta_value break loop
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- Not able to get my custom search result using meta_query and tax_query together?
- Meta query broken since 4.7.4 Update
- Querying, storing, and using data from 2 separate custom post types
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- Selecting posts older than the current Unix epoch timestamp
- Custom Query With Multiple Meta Key Value
- using post_type with meta_query
- Ordering by multiple meta keys – Custom post type
- loop through custom post-type with two meta_keys
- Querying meta values within an array
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- add_filter > posts_where works partially
- Get Posts ordered by a date custom meta field
- Order Wp Query by earliest of 3 dates meta query
- WP_Query() displaying past post / event
- WP Query Conditionally query meta and taxonomy
- Meta_query question