You can’t do that. When you save postmeta (or any other meta, for that matter), WordPress runs it through maybe_serialize
which turns objects and arrays into serialized data. When it gets pulled back out, it is run through maybe_unserialize
.
Serialized data looks something like this:
a:1:{s:3:"one";s:3:"two";}
In other words, what get’s stored cannot be queried in the way you want. The best you could do is a LIKE
query, which will be unreliable at best and less performant. Just use LIKE
as the compare
argument of your meta query.
Your best bet: rethink how you store meta and move whatever key
is to its own entry. Meta tables in WordPress are key value stores, it’s not unreasonable to store multiple meta values per post type or plugin.
Related Posts:
- When to use WP_query(), query_posts() and pre_get_posts
- WP Query Args – Title or Meta Value
- WordPress Pagination Not Working – Always Showing First Pages Content
- Whats the difference between post_limits and pre_get_posts?
- WP query taxonomy input differs to output?
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Query WooCommerce orders where meta data does not exist
- How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?
- What exactly does the ‘s’ parameter search for in WP queries?
- WP_Query min and max values
- get_posts not finding argument: post_name
- get query’s query string
- Show only oldest post by author
- assign 2 $args to one wp_query
- Revolution Slider Orderby Two Custom Fields
- Calling a custom excerpt function in a local loop
- Exclude first 5 posts of specific categories in the main loop
- How to bring specific post to front of wordpress loop?
- How can i get the last post from wp multisite?
- Use meta_query to display events by date in custom field
- How to show min 1 post from specific categories/tax WP_Query?
- Posts loop with pagination on a single post page
- WP_Query & AJAX
- Sticky Post default functionality with WP_Query is ignored when using AJAX
- Tell wordpress to show a single page instead of an archive
- Using one WP_Query object within the loop of another WP_Query object
- how to merge a WPQuery array with a PHP array and use the Loop to Output the result
- Order by slug in get_terms with multiple taxonomies
- Orderby ASC changes to DESC in WP_Query
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- How to access WP database inside ipn.php? [duplicate]
- How to get only return parts of WP_Query result for performance?
- how to make members list directory through wordpress post custom meta key.
- posts_per_page not working for first page of pagination
- Advanced ordering of query_posts
- How to get a query variable?
- Taxonomy and Date in same query?
- echo a specific meta_key queried through a custom post
- WP_Query returns posts_per_page + 1 every time
- Custom WP query with polylang term
- All posts returned when author of 0 is queried
- Merge two search functions for custom post type
- WP_Query – Accessing MetaValue from Query Result
- problems with comments_number()
- get_the_terms – but only show 4 Posts
- WP_Query object: what’s the difference between [query] and [query_vars]?
- Does WordPress have something like Drupal’s DB API?
- Hide products in uncategorized category from search results
- Is it possible to add relation between meta_query and tax_query?
- PHP – Loop custom post type categories within jQuery Tabs
- How order posts from category by date and comment count?
- Get a list of ACF Repeater-Fields as array
- query_vars empty when using custom url with custom rewrite rule
- Get query results with a page title
- Show single posts date, in a page of posts
- How to filter multiple queries with search?
- Compare “Main” post ID to ID inside wp_query loop
- WP_Query Class custom field parameters
- Attempt to display site authors in a carousel – User Image not Outputting inside li tags
- problem with the loop
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- Why my query is not “Main_query”?
- WP_Query for distinct meta values
- Group Product Types
- Facing problem with tax_query results
- How to add a “base” filter for all posts visible to visitors on the site?
- Save queried result into database
- sanitize_post() is not sanitizing Post Object
- WP Query by variable custom field
- WP_Query multiple value not working
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- wp query search multi terms
- Translating WP query into to SQL query
- How to get top rated posts using wp query?
- Unusual high query of user meta data
- Woocommerce featured products query no longer working
- add action for wordpress query at a specific position
- Tax_Query not working – connecting to second wordpress database
- How to search CPTs in draft using get_page_by_title()
- WP Query Meta Query
- Updating an intensive wp_query result once daily
- Custom WP_query and integrating into theme file
- Empty ‘terms’ in ‘tax_query’ returns an empty array
- Archive – Show Page Month Headers
- Get newest value of an array
- Return a single custom post from multiple meta queries
- ordering and optimizing functions
- Why does order ASC break offset in WP_Query?
- new WP_query using custom fields
- Having Trouble Running Query From Shortcode Using Tribe’s Events Plugin
- Change ‘post_modify’ with a query
- An archive page without post format (just standard post)
- query post based on comparison
- Dynamically create array from page title
- Ordering Custom WP_Query loop by meta key value with pagination
- wp_pagenavi on WP_Query using customfields
- paginate_links() on page (shortcode output)
- WordPress Query Returning Every Post
- shortcode with $atts with strange results
- How to efficiently find “duplicate” posts, where the titles are different, using metadata to match posts?