This is not going to work, because you are setting same meta_key
parameter twice with different values and only one will be effective.
Rather than building raw queries it is better to use filters to modify WP query. Query Overview documentation has list of hooks where you can insert your mods (as the end under What Plugins can Modify).
Related Posts:
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- Is there any action filter/hook for validating a custom field before publishing the post?
- Filter WP_Query for posts having a certain meta-value
- Apply the_content filter to a custom field with multiple values
- Pass all custom fields through the same filter on post load?
- Filter results with custom field values and dropdown
- Archive sorting functions by custom fields (front-end)
- Change content before writing to database
- WordPress Search Custom Meta Field Only
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- Using custom fields in a filter hook
- Add an advert every nth Paragraph
- How to filter a dd/mm/yyyy date from a custom field in a query
- Force hide custom field metaboxes
- Saving custom profile fields
- Update posts after populating ACF field value [closed]
- How to validate custom field on lost password form before the user id field?
- Sorting WordPress Posts via Custom Field Values?
- filtering custom post types via meta data drop down
- global function to apply filter to custom field
- Filter multiple custom fields Values with Check boxes
- How to get categories with posts by custom field value?
- How to Wrote Simple Calculations by Using Custom Fields in Loop?
- Best filter to use for modifying custom fields on a post?
- How to display childrens custom fields?
- Access ACF fields within custom preview function?
- Sort posts by clicks on download button
- Let Users Filter Posts by Custom Fields
- Custom Theme Fields in Settings Menu – apply filters to one of those fields?
- Footnotes in custom fields
- How to change permalink on headlines in rss feeds?
- How to change order of posts in admin
- How to query posts by month based on date custom field?
- Filter or order based on custom field
- How to show ACF fields in Gridbuilder custom block
- WP meta_query args not working in function
- User Filter Options on Archive Page
- How to add content with a filter when there’s no content in the editor
- Admin – Search Events by a custom field
- change attachment custom field onChange event
- Filter and display a specific custom field value [closed]
- How to filter post using custom feild value in shortest and longest duration?
- Query Posts Via WordPress URL
- Checking if field is set before comparing with meta_query in query_posts?
- Create widget that filters posts on current page based on entered value
- Including inline Custom Fields info with add_filter in functions.php
- Sort posts after filtering them through multiple taxonomies
- Set new url from custom post field
- Add a Jquery Datepicker to custom field in post edit
- How can I avoid re-inventing the Custom Fields wheel in my Plugin’s Metabox?
- Does wordpress have something like content-type?
- Order Posts by Closest Numeric Values
- How to get and edit custom fields if in Quick Edit
- Create additional short URL with custom field and 301 redirect
- Create custom field on post draft or publish?
- get_post_meta fields don’t show up on posts page
- Function to change meta value in database for each post
- Include woocommerce custom field value in front-end search result
- WP_Meta_Query causing long-running MySQL queries
- MySQL Query that looks for post with Custom Field, then changes Category
- Woocommerce: Custom fields and email shortcodes, ec_custom_field
- Tweak Meta for Post to work it for Pages also
- Create Pop-Up Box with Custom Field Content Inside the Loop
- Adding an editable field to template?
- Transferring author information from a custom field to a proper author
- How to select posts from multiple categories and metavalues?
- How do I Implement Atomic Update of Post Metadata?
- Custom fields value
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Want to make A CSS if meta key value is empty
- Add & store extra fields – WordPress Comments
- Outputing a metabox textarea and avoid line breaks inside li tags
- Restrict WordPress Search to Custom Field
- how to display an excerpt of the latest post on the homepage?
- How to add a custom field to a post created programmatically?
- Custom post type missing custom fields
- Problem with saving large amount of data in postmeta/usermeta
- How to get posts with a metadata numeric key greater than X?
- “Matching” or “Linking” Two WordPress Pages: Custom Fields?
- Meta_query ‘compare’ => ‘LIKE’ not working?
- Get text from user and display it on page
- Upload & include specific JavaScript files for posts?
- If metabox has content display content
- Custom meta boxes not saving
- Listing the most popular 8 city (custom fields) as used in posts
- How to delete file uploaded by Plupload
- Display Meta Data with HTML?
- Order by custom date field
- Group Posts By Custom Meta Value: Date
- Meta field bulk editing no longer working in WP 6.0 [closed]
- Custom Field: how to save array of multiple key-values in WordPress
- Delete user meta but only if found in array
- Custom field in media library not saving, selected() function not adding “selected” to select list input type
- meta_query to check all custom fields
- Show Custom Taxonomy as Headline for related posts
- Custom field group on page
- display Flexible Fields from options
- list pages by custom_field?
- Get custom field from page, in a post?
- Advenced custom fields auto fill problem