Hi @Rob:
The reason you can’t figure out how to do it is because it’s not possible, at least not without resorting to SQL. Try adding the following to your theme’s functions.php
file:
add_filter('posts_where','yoursite_posts_where',10,2);
function yoursite_posts_where($where,$query) {
global $wpdb;
$new_where = " TRIM(IFNULL({$wpdb->postmeta}.meta_value,''))<>'' ";
if (empty($where))
$where = $new_where;
else
$where = "{$where} AND {$new_where}";
return $where;
}
If you have custom 'featured_image'
fields with empty values the above will filter them out. If you problem is something else, we’ll have to see what your data looks like to solve it.
One thing I’m curious about; how did you get empty values for 'featured_image'
? The admin UI in WordPress 3.1 does its best to keep you from entering empty values.
Hope this helps.
Related Posts:
- Sorting Posts with meta value not working
- Can wp_query return posts meta in a single request?
- order by numeric value for meta value
- How do I query for posts by partial meta key?
- Use REGEXP in WP_Query meta_query key
- WordPress retrieving meta data for all custom post types in list view
- Order by optional meta key?
- meta_query: using BETWEEN with floats and/or casting to DECIMAL
- Reduce or prevent calling of update_meta_cache
- Is there a way to extend WP_query so Custom Post Types can have properties?
- What is the most efficient way of querying posts based on visits and date for current day?
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Getting attachments by meta value
- WP_Query displaying ALL posts
- meta_query where value is equal to given value
- Query Custom Meta Value with Increment
- WP-CLI How to generate a list of posts with corresponding meta values
- WP_Query with meta_value LIKE ‘something%’
- What is an efficient way to query based on post_meta?
- WP_Query not working as expected for attachments and custom meta_query
- How to count post meta key values for all posts in database
- Group posts by meta_key
- How should I use posts_where to change meta_value from a string to integer?
- How can I create a WP_Query that returns posts where one meta_value
- Sorting meta_value as integer doesn’t work
- 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 fire join query with post_meta
- Best approach to create Hot and Trending sections
- WP_Query, custom sort and custom filter
- Add a default meta_value to new posts
- Order posts by meta value and Date
- Efficient way to update multiple post meta
- Ordering by meta_value AND date NOT WORKING with wp_query
- How to make orderby ‘meta_value_num’ OPTIONAL?
- How to use Meta Value Compare in WP_Query For Max and Min numbers
- Custom WP Query from meta_value stored as serialised array
- meta_query works locally but not on live server
- Ordering Posts Type A by Custom Fields of related Post Type B
- Query Posts depends on custom field inside repeater field using acf
- Query post with meta_query where date is not in future
- Minimising Database Queries when using Advanced Custom Fields
- Get meta info related to current post
- Select from wp_post and multiple meta_value from wp_postmeta
- Pull post meta with post_query?
- Group WP_Query by meta_key date
- WP_query posts closest to todays date
- Custom query for sidebar isn’t returning results
- Need wp_query to return all children and grandchildren
- exclude posts with a specific custom field and value
- Inserting serialized value into wp_postmeta using update_post_meta
- How to make Meta Query case sensitive?
- Performance when getting post meta for post retrieved by meta value
- Display posts from multiple value in meta separated by comma
- Custom filter from post meta
- Why can my filter query SOME metadata but not other metadata?
- Query against multiple locations within single custom post type post
- update_post_meta performance in a loop woocommerce
- update_post_meta performance in a loop woocommerce
- How to set meta_query if get_post_meta returns nested array for that key? [duplicate]
- I need query_posts() to order results first by a meta value and then by post ID
- Look for string in posts and postmeta
- Query postmeta based on meta_value, return array of post_id
- update_post_meta() not updating
- Gather same custom field values in one value in a select tag with wp_query
- I can’t get post based on its postmeta value and key
- Saving custom fields for WP_Query to retrieve
- Meta key in wp_query bug?
- How to show all the associated posts with specific date of data metabox?
- Order posts by more than one variable (meta_key and publish date AND time)
- WP Meta Query at depth 2
- WP_Query with child element
- Sort by meta key within same day
- WP_Query Posts by Metadata from Option Tree
- how to query for meta_value have array
- How to get several fields from wp_query?
- Cannot order by in WP_Query
- WP Query to order posts by multiple meta fields
- Return a single custom post from multiple meta queries
- Custom Search Query – include only custom fields and title
- Query to get all the posts of more than 2 meta_value having same meta_key?
- How to count post meta key values for all posts in database
- How to query post ids liked by the Author
- loop through custom post types with meta data
- query by meta value then date and not empty meta value
- Order by meta values
- query_posts, oderby meta_value & print “future” posts
- wordpress sorting using array merge by price in ascending order but price with 0 must be show last
- Query posts by meta value and sort by another meta key
- Get posts by meta value except one post [closed]
- WP_Query by meta key not returning any posts
- Extend search query to search meta keys values based on search string
- How to get posts that have certain meta key value and order based on another meta key’s value
- How to `’orderby’ => ‘meta_value_num’` in a series of orderby parameters