Checkbox field is stored as serialized array, therefore you can not use the IN
operator and array with the values you are looking for.
To get posts with checked “melbourne”, change meta_query
to:
$meta_query = array(
array(
'key' => $name,
'value' => '"melbourne"',
'compare' => 'LIKE',
)
);
To get posts with melbourne
or sydney
:
$meta_query = array(
'relation' => 'OR',
[
'key' => $name,
'value' => '"melbourne"',
'compare' => 'LIKE',
],
[
'key' => $name,
'value' => '"sydney"',
'compare' => 'LIKE',
],
);
Think about changing the solution, because these types of queries negatively affect performance.
Related Posts:
- Filtering a WP_Query meta_query by numeric values isn’t working
- filter search result with custom post type meta key
- List events by month
- Can’t sort order of wp_query with 2 meta keys
- Show ACF field from custom taxonomy and display on the single template
- Change message given when deleting post from custom post type
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Link users to a custom post type
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- get_posts of Custom Post Type AND Custom Taxonomy
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- Stuck in Order by more then one
- Meta Query Not Returning Output Despite Having Matching Values
- search suggest – filter post type
- How to update post meta on uploaded image from a custom form?
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Displaying custom field according to date
- Query based on custom fields start and end date
- Create short URL with auto 301 redirect
- Query entries from custom post type in an ACF flexible content field
- meta query not retrieving posts
- Using WP meta query to show custom post types by a start and finish date
- Fetch data from two custom post types and create multidimensional array for output to html table
- Custom front-end form for adding post – Category problem
- count & sum the value of custom field of the author post in dynamic posts
- Grouping custom wordpress post types by acf value
- Filter result of Custom Post Type using meta_query with ACF
- WordPress – display relationship between blog posts and custom posts
- Query posts by current ACF meta key value on single page as related posts
- Custom sorting in post columns by ACF Pro Select Field
- Load info from customposttype into template page
- ACF meta_key and meta_value break loop
- Display Specific Posts at Start of Loop
- How to get the posts that my following users are liked?
- CPT: execute code after load if parameter is set
- ACF Post Content Not Being Searched
- Display related post content and custom field content
- Meta query broken since 4.7.4 Update
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- Can’t pick up a field created with Advanced Custom Fields
- Custom post tag images not displaying with ACF
- Get month and day from a Date Picker custom field
- using ACF datepicker to filter posts on a page
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Trying to combine multiple WordPress queries
- Custom Post-type not returning the right child_of
- Getting ACF relationship field information
- How to I add count of custom posts listed in a post as a prefix to its title
- Meta query with ACF relationship field
- How can I filter records in a custom post type list in the admin based on the ACF field in the post that contains the current user?
- WP Query to displaying date and posts for that date?
- GravityForm: Populate Dropdown with custom post type [closed]
- Return array of categories to php function for current post
- Custom search for custom post meta with pre_get_posts interferes with WP search
- Create a random unique 6 digit number as custom field for custom post type
- How to output wordpress custom tags separated by comma?
- 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?
- Remove duplicated values from a loop
- Query that joins the postmeta table twice
- Loading all files within a directory
- Issue with pre_get_posts on custom post type archive pages
- Blog page showing same content as homepage
- Using pre_get_posts to filter one loop in a multiloop archive
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- How to sort custom post type posts in default order by multiple fields?
- Using several custom fields as custom post title
- Custom Post Type without an archive page
- How to retrieve category NAME instead of ID in a function with a taxonomy custom field?
- Get rewrite slug of custom post type in template
- Show Different Header on a Specific Post ID
- “add_post_type_support” with Custom Post Type & ACF
- Custom post type show on both Home and Date Archive
- Get Post Primary Category
- Custom Post type with ACF in REST API, how do I get those values?
- Weird problem happening with custom taxonmy when creating/updating posts
- ACF simple text field value not showing
- meta_query compare >= not working but
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Post Object Filter by Custom Field, not title (ACF)
- Custom Post Types not showing, custom WP_Query
- Admin notice not displaying
- Can’t get order_by meta_value_num to work properly
- Create custom post type on successful woocommerce order [closed]
- Rewrite WordPress URL to show CPT meta field data
- pre_get_posts on custom post type
- advanced search forms with 3 input text and that the main problem 3 input text
- Create 3 Level Relations with ACF and WordPress
- Custom Post type and Custom Field WP_Query
- Display multiple custom post types and sort them chronological by one of their fields
- Adding custom tables to WordPress
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Very Slow Page – How to Optimize # of Queries?
- Pull a post based on a meta value in a custom post type
- Dynamic page outside WordPress
- Using wordpress template tags within an array
- Getting the URL of the parent page
- Custom query to filter posts that have current post as a taxonomy [closed]
- Multiple ACF Repeaters within a Custom Post Type
- How to change post featured image using a custom field of category?