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
- ORDER BY custom field value
- Best way to programmatically remove a category/term from a post
- Custom user avatar in the WordPress users listing
- query_posts and only show results if a custom field is not empty
- User Profile / Add Custom Fields
- Convert jQuery Datepicker Format to SQL Date Format
- Only show metabox when date-value in other metabox is over?
- Is it possible to store arrays in a custom field?
- HTML / Javascript in custom field textarea?
- How to convert custom field value to tag
- Saving an array in a single custom field
- Order posts according to user defined order for meta values?
- Calculate the sum of certain the_sub_fields
- Is it possible to order posts by two meta values?
- My metabox class
- Alternative to simple fields plugin?
- wp_editor not saving data, and text area showing html tags
- Get specific custom field keys from a post and put into an array
- Importing from XML is ignoring serialized custom field
- Select multiple options in WordPress custom meta filed
- Get content from pages with same meta_key from Database
- How to add an extra field in a post and show it on the template
- Exclude images uploaded via meta boxes from WordPress gallery
- Front-end editing with custom fields?
- If meta key exists in get posts function otherwise create it
- Bulk append custom field to post content
- Pass current post title to a predefined link
- Migrating old posts to new wp, how to extrapolate infos from the post body to custom fields?
- shortcode in a custom metabox
- Vimeo thumbnails
- Save attachment ID instead of URL in custom field
- Displaying a custom field containing a list creates unwanted markup
- Output custom field as ul list
- Multiple Custom Field Query
- Change Page Order by Custom Field (Magic Fields)
- Custom Field is getting the value of another page/post instead of the current one?
- Custom Field Date Problem
- Approach to creating a site with this structure
- how to turn a link field into a button or link text
- Use value from ACF to populate other fields
- Dynamically populate query source in Elementor post widget
- Why does my numeric meta query work only on one meta key and not the other?
- Show image depending on the number in the custom fields
- author global display format
- Problem saving meta data
- Term specific featured post on taxonomy archive pages
- WP_query returns error when used for custom widget
- Saving metadata of related post on save_post
- Custom field value link title
- How to Order Posts by Custom Fields?
- Post rating using Custom Field
- Inserting custom fields into new-post.php without using the Custom Fields Template plugin?
- How can I attach files without using a plugin?
- Advanced Custom Fields for Header that are Editable from a Page [closed]
- Change Fields of Comments and make them searchable?
- Shortcode not picking up custom field
- Order by a meta field in query loop