You can use meta query in wp query to get required posts
$args = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'city',
'value' => 'Melbourne',
'compare' => 'NOT LIKE'
),
array(
'key' => 'city',
'value' => 'Melbourne',
'compare' => 'NOT EXISTS'
)
)
);
$query = new WP_Query( $args );
Related Posts:
- Order posts by custom field and if custom field is empty return remaining posts
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- Echo values from custom field outside loop php
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Calling custom fields for pages (not posts)
- Duplicate posts being displayed when querying Custom Fields
- Loop to display random posts only if a custom field matches category
- How can I show custom fields in the loop only to specific user roles?
- get_posts that match a user-specified value on a page
- Accessing loop functions (e.g the_title or the_content) from post ID
- Limit the number of acf content when displaying in post loop [closed]
- Is there a better way to list all database terms alphabetically?
- Change the main loop WordPress impact on the server?
- custom-meta-box checkboxes from loop won’t save
- How to show a post if was published less than two hours ago?
- List users by sum of all their posts’ custom field values
- Custom Fields – How to create a list from multi-line entries of a single value
- how to make nsfw post with thumbanil
- Custom Query based on custom field of a single post
- Efficiently sort only certain categories by custom field
- Can I access a post meta field before the loop?
- Displaying page image in the footer automatically
- Show image if author meta (profile fields) exists outside loop
- Can’t query by meta_key
- ul list with only as many li’s as filled custom fields
- Loop through incrementing custom fields
- do_shortcode close
- Search Results Page – Displaying Custom Meta Fields
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- Collect Data from NEXT item while in loop
- How to show content of custom fields in search results?
- Custom field outside the loop and inside an array
- Display metabox title for custom fields with values
- use custom field value as post category in loop
- Filter or order based on custom field
- Compare ACF date field (if exists) and post date and order DESC
- excluding posts by an ACF field in pagination
- What am I missing in this Code Block?
- get_field values for each post on home page using wp_add_inline_style
- User Filter Options on Archive Page
- Custom meta boxes – add php code inside?
- get wordpress post loop by meta box date
- Outputting custom field on home.php not outside of blog list
- Counting number of images from loop
- Metabox value for post loop?
- Get meta value when the page is a blog archive
- WP_query returns error when used for custom widget
- I want my post to republish again after adding a custom field
- Display posts where date field matches current month?
- Filtering posts by WORD in custom field
- Retrieve IDs from custom field, count and display results differently according to count
- Pagination not displaying correct number of pages
- Display custom field outside the loop
- Custom field not showing
- Order by a meta field in query loop
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Add custom fields to search
- How to get users by a custom field / by user meta data?
- Auto sort the wp-admin post list by a meta key
- Add custom field to image editor
- TinyMCE in Custom Metabox not loaded after upgrading from WP 3.1.4 to WP 3.2
- ajax delete value from custom field array
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Custom field for default gallery
- After moving my site from a dev subdomain, to root, all my custom meta data is gone
- WordPress Custom Field Should be Unique. Is it possible?
- all tincymce’s switch when updating page after changing from html to text in custom metabox
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- nextgen gallery: how to get picture url by gallery id
- How to add posts through CSV or excel file in a PHP file
- Can’t display errors in attachment_fields_to_save
- When creating a metabox do you have to create DB fields for the data?
- Best filter to use for modifying custom fields on a post?
- How do I query the title (or handle?) of post meta fieldset (created with Simple Fields Plugin)
- Is it preferable to use custom code to create metaboxes instead of plugins (such as ACF) and if so why? [closed]
- Function that replaces the image in the absence of the post meta
- Is there a way to dump all registered sidebar/widget?
- How to hide post meta
- ACF Plugin How to make the customer add more fields in the post?
- custom field in admin columns
- get_post_meta returns 0
- Users uploaded image and matching an id or taxonomy
- Let any visitors delete a post if they know Id nr & password?
- update a custom field with the value of another existing custom field
- Post meta data not showing in frontend, until hitting ‘update’ button
- Ordering posts by custom fields (Date)
- PHP and Shortcode Combination
- Retrieving Advanced Custom Field within Shortcode Function [closed]
- How to properly get popular Posts by multiple Values
- Get custom fields when hover link of post
- WP Query multiple select form – meta_query help
- update_post_meta not working in action hook
- Group pages by custom field values
- How to check if custom field exists in this widget query
- display loop only if a post meta data exist
- Add Custom field under the post title [closed]
- Check if a field is capitalized?
- Can’t sort custom column on user.php by number / meta_value_num?
- Need to call this php function inside a modal window from text widget