take a look at the reference docs for the WP_Query class: http://codex.wordpress.org/Class_Reference/WP_Query
something like this:
$args = array(
//some key/value pairs...whatever
'meta_query => array(
array(
'key' => somekey,
'value' => somevalue,
'compare' => some comparison operator
),
array(
'key' => some other key,
'value' => some other value,
'compare' => some comparison operator
)
)
)
$my_query = new WP_Query( $args );
//some code to do something with the results of the query
Related Posts:
- List custom field values in alphabetical order without repetition
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Max length of meta_value
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- get_pages sort alphabetically by meta value
- Assign/update the custom field value for all posts
- Order by custom field date with ASC order
- How to break meta values into different items and avoid duplicates?
- WP_query : meta_key with custom rule for specific value
- How to sort category by custom field value
- trim custom field text value and show (…)
- Query post order by post and desc not working
- How to wrap meta values seperated by comma in ? [closed]
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Run a check for multiple meta key values
- Filter by custom field (meta_key) using JSON API
- Removing link ” from ” on meta_value in custom feilds
- Sort alphabetically by custom field
- pre_get_posts : only get posts by wp_usermeta value
- meta_value and meta_key filtering returning no posts [closed]
- IF Custom field value equals ZERO
- How to update a custom field in all posts with the value of another custom field in the same post?
- Update post meta custom field using block editor
- How to add custom filed value after in wp post title
- Sortable Custom Columns not sorting correct
- query_posts with meta_value
- Show array of meta_value in Edit Post Coloum
- Making WP_Query limit results by date before today where date is a meta_query
- User query – getting values for custom meta keys/fields
- get posts based on non-single metadata
- Best way to insert a list of links into a post outside of the_content
- Set class if a meta value is set within post archive
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- How to get all wp_posts in wordpress fetched from database
- Create Shortcode shows only posts with custom_field meta
- 4 Unique Random Posts based on Custom Field Values
- Custom Field: Display only if a specific key is selected outside the loop
- Insert shortcode before and after a list automatically
- How can I display only the post titles from a selected category in columns?
- Foreach giving one too many list items, how can I remove the last empty line?
- WP Query Args – search by meta_key or title
- Saving multiple custom meta box fields
- get Custom field label (select/dropdown) on front end
- Can I count every article following extracted meta value?
- Best Practice for storing aggregate data by date or other criteria?
- Block Editor – Meta values not saved, meta changes to empty array on update
- Show only posts which can be commented OR have custom meta field
- Need small coding with Custom Fields Search
- get_post_meta() unserialize issue – returns boolean(false)
- How can I remove fields in the attachment editor?
- Correct Approach for Validating Custom Field Input
- Query meta field using between
- Delete post based on a custom field?
- How to make custom comment fields required and message field not required
- Dynamic User State & City selection
- Update meta values with AJAX
- How can I migrate all of my custom field thumbnails to the built-in post featured image?
- Custom fields to save multiple values
- Extend ‘The Events Calendar’ search to include custom fields [closed]
- Add field to ‘Add User’ admin page
- Escaping Quotes
- wp_editor removes paragraph from custom meta box
- Any way to include custom fields in WP_Query results?
- Using a checklist to search against metadata
- Where did the Add New Custom Field go?
- Admin meta Image Path
- Can’t get metabox value (a url) returned using WPAlchemy
- Syntax highligting for custom fields
- Displaying a checkbox array from advanced custom field
- How to create a dropdown select of all items in an ACF field group
- Getting Custom Fields from WordPress JSON API [closed]
- Ordering posts by custom field named “date” in backend
- How to pass page as an argument like post in WordPress?
- How to display custom fields from a plugin
- Adding “meta” info to WP site PHP function?
- WordPress Media Uploader custom Javascript not working
- Custom fields issue [closed]
- Select custom posts by meta_value and sort by a different meta value
- List custom queried terms in the edit-tags.php?taxonomy page
- Front end register with custom fields
- Display custom field from the front page on another page
- Display custom widget value in header.php
- Gravity Forms Update post meta from template [closed]
- Automatic linking terms
- wpdb function insert doesn’t work
- Get Custom Field Name ( Label or Key ) Not Value
- Adding Custom Metadata to my Archive/Posts page
- Ordering by ACF custom field vaule
- add different custom fields value to post class if permalink or index
- Login_form add to top of form rather then bottom
- Advanced Custom Fields from Category – IF statement
- Get a different meta value with ajax when different elements are clicked
- Delete custom fields on post publish?
- How do you turn a custom field’s value into a permalink for that post?
- Permalink structure depending on custom field
- Using Hooks. Thematic
- Parse Shortcodes in Theme’s Custom Field?
- Update field name without losing the value
- How do delete a meta key?
- Custom post type needs to capability to create and edit by some specific user role