OK, I found the answer here:
Turns out you have to use the serialize
php function due to how wordpress stores arrays in the database.
function get_city_jobs() {
$city = ($_GET['city']);
$city = trim(ucfirst($city));
$args = array(
'post_type' => 'careers_post_type',
'numberposts' => -1,
'meta_query' => array(
array(
'key' => 'city',
'value' => serialize($city),
'compare' => 'LIKE'
)
)
);
return get_posts($args);
}
Related Posts:
- Get_post() with meta_key when compare is a date
- Get posts for which a custom field is not present, with get_posts
- get_posts custom field
- Posts query according to meta box date
- Mathematical operations on custom field values? (updated)
- When to use WP_query(), query_posts() and pre_get_posts
- WP_Query vs get_posts
- Get posts from Network (Multisite)
- Sanitation needed for WP_Query or get_posts calls?
- Sorting posts by custom date fields (non standard date format)
- Use of caller_ get_ posts
- How-to exclude terms from the main query the most performant way?
- get_posts not finding argument: post_name
- Meta Query with date and time on the same Day before given time
- Group posts by custom field
- Get posts with condition on comment meta value
- getting posts and number by specific meta value in multiple meta
- What should I use, get_posts or wp_query for less CPU load?
- Revolution Slider Orderby Two Custom Fields
- How to get post from all Blog Multisite to the Main Site?
- Query two post types and order by two different date fields
- get_posts() seemingly ignoring post_type
- Can not switch the queried post in pre_get_posts hook
- Count posts returned by get_posts in external PHP script
- How can i make WP_Query return post image and categories?
- How add a custom posttype name using ACF field to a query post array
- Ordering Posts Type A by Custom Fields of related Post Type B
- WP_Query, tax_query and term_meta: How to?
- get_posts – get all posts by array of author
- Search Posts with Custom Fields as query
- Creating a custom search for a specific post type
- get_posts() not working with multiple statuses
- Return only post(s) which have post_excerpt
- Add quicklink to in the Admin posts page where I can query by a meta_key
- How to make Meta Query case sensitive?
- Meta_query with multiple keys and multiple values
- WordPress Comments sort by custom meta key
- Understanding the orderby in WP_Query?
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Order by empty custom field
- Query posts without meta preload
- WP_Query post_parent parameter always returns children of current page
- Query all posts if multiple meta key don’t exist
- meta_compare not comparing whole integer
- How to count posts with specific arguments
- wp_query to print posts if have X custom field value
- Why is WP_Query not displaying expected data?
- get_posts output always same post
- get_posts() and global variables
- complex get_posts() query to select child pages
- WP_QUERY with group by with custom fields
- How to order posts on each different category?
- Intiger meta value with ‘>=’ returns posts with lower value
- Get every post with value in meta key
- Order WP_Query results by meta key value in custom query
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Group by custom field value (start and end times)
- How to get posts by category and by choosing a taxonomy term?
- Function using get_posts() with tax_query not working when called from functions.php
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- Sorting posts by Multiple custom fields in defined order
- Search for pages with permalink
- Execute PHP function inside the admin area
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Why my query is not “Main_query”?
- Facing problem with tax_query results
- How to add a “base” filter for all posts visible to visitors on the site?
- Sort custom post by custom field if none order by latest release
- Populate select list with meta values from all posts of a Custom Post Type
- Form checkbox value going to dynamic URL
- get_posts return only first result
- How to get meta key list efficiently?
- Getting posts by custom field value
- how to get wp_query posts only first letter of alphabet A?
- ACF Post Object meta-query by title not ID
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- Query by meta value (add a dropdown of all values)
- Order Posts By Custom Field That is an array of objects
- Custom WP_query and integrating into theme file
- Query by Category and Custom Field – Shortcode
- Querying posts with meta key and meta value not returning anything
- Ordering Posts by parent category, name ascending
- Use not custom fields in get_posts() meta_query?
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- Compare meta key separation
- WP_Query a custom field value bringing back 0 results
- new WP_query using custom fields
- get_posts works but new wp_query doesn’t
- query_posts with sorting on a custom datestamp
- Why WP_Query in functions.php is not working when get_posts works?
- query post based on comparison
- Query posts filter not working
- Query specific number of posts for each post type in specific order
- Display all custom meta field values from the database using ACF Repeater
- Taxonomy related query not working
- get_posts shows current post, not defined posts with args
- Query custom post types by meta field in a term from custom taxonomy
- WordPress extremely slow when using get_posts with multiple meta_query relations
- WP_Query sort by ACF date field (newest first) with blank dates first
- Sort by multiple columns using get_posts