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
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- WP_Query – Order results by meta value
- getting all values for a custom field key (cross-post)
- How to add a custom field in the advanced menu properties?
- Custom query with orderby meta_value of custom field
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Add validation and error handling when saving custom fields?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Show Custom Fields in Quick Edit
- Where are custom field values stored in the database
- Validating Custom Meta Box Values & Required Fields
- Max length of meta_value
- Add custom fields to wp native gallery settings
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- How to enable custom fields for pages (if not a bad practice)?
- How can I add extra attribute in the ‘Page Attribute’ section in wp-admin for pages?
- Is there a way to set default custom fields when creating a post?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Custom field/meta populated by dropdown of existing posts?
- Difference between meta keys with _ and without _ [duplicate]
- Filter by one custom field, order by another?
- Remove Dimension from wp_get_attachment_image
- Orderby meta_value only returns posts that have existing meta_key
- Underscores in custom fields
- What is the index [0] for on post meta fields?
- What is “meta_input” parameter in wp_insert_post() used for?
- Query Posts or Get Posts by custom fields, possible?
- How to enable revisions for post meta data?
- Sortable Custom Columns in User Panel (users.php)?
- Any way to add custom options to Gallery Settings?
- The “_encloseme” Meta-Key Conundrum
- ORDER BY custom field value
- Individual Widgets per Page
- Add subtitle to Woocommerce product title
- Best way to programmatically remove a category/term from a post
- Importing data for advanced custom fields plugin?
- Gutenberg add a custom metabox to default blocks
- SQL Query to copy value of a meta_key into another meta_key
- ‘Preview Changes’ for custom meta boxes?
- Adding a custom field to the site identity menu
- Using TinyMce with textareas in meta boxes on custom post types
- How to correctly call custom field dates into a posts_where filter using SQL statements
- Using get_post_meta with new_to_publish
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- Add a Jquery Datepicker to custom field in post edit
- add meta box – custom field : which to choose?
- Preserving line breaks when saving and displaying custom fields data
- How to return Meta data from the REST API?
- Advanced Custom Fields – Get custom fields from parent page