Try this one
<?php
$date_today = time();
$args = array(
'post_type' => 'birthday',
'posts_per_page' => 1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'field_position',
'value' => 'Teacher'
),
array(
'key' => 'field_dob',
'value' => $date_today,
'compare' => '=',
)
)
);
$the_query = new WP_Query($args);
if($the_query->have_posts()) : while($the_query->have_posts()): $the_query->the_post();
the_title();
endwhile;
endif;
?>
Related Posts:
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- Add indexing to meta_value in wp_postmeta
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Custom WP_Query order by post_meta and (author) user_meta
- Using custom meta_query with relation not working as expected
- Perform query with meta_value date
- WP_Query meta_query where meta value ends in space
- Nested query inside Logical operator OR not working in meta_query
- What is an efficient way to query based on post_meta?
- datetime picker, timestamps and meta queries
- How do I create my own nested meta_query using posts_where / posts_join?
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Exclude post on loop by multiple meta key value
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- How to get sum of meta_values of a meta_key in wp_query according to conditions
- meta_key and meta_value not working together
- Order posts by meta value and Date
- Query sticky posts with thumbnails
- Order WP Query posts by custom order calculated from post meta values
- how to speed up a complex wp_query?
- Meta query with order by another custom field
- How to query for custom field within Gutenberg block from outside of that post? [closed]
- Meta Query for specific months
- Meta query with JSON value
- Get meta info related to current post
- Creating arguments from loop for WP_Query meta_query
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Single meta_query query using OR instead of AND in request’s WHERE statement
- ACF Date Based wp_query
- How to do meta_query for attachments?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Get attachment by meta_key value
- Using meta_query with multiple keys and compare values
- Mysql query and order meta value
- Why isn’t my `meta_query` array functioning properly?
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- meta_query BETWEEN, but the range is stored in the custom field
- Suggestions on making this query/code more performant
- Is it possible to set specific posts to show first in a query?
- Order by meta value (numeric value lower to higher)
- Large AND OR query timing out
- Order ascending is ignored in meta query?
- WP_Query with different postmeta filter for each categories
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Meta Query doesn’t works as espected
- Advanced WP_Query with meta_query, orderby?
- Issues with search after added meta_query
- Sort by presence of thumbnail
- Display posts with specific value first in query
- Sorting search results with custom dropdown
- WP_Query: apply an SQL function to meta fileld value
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- query post by author gender
- How do I add an item to the WP admin menu?
- Multiple meta query from array
- WP_Query with 4 post meta field arguments gives 500 internal server error
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- What’s missing in this wp_query and meta_query
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Custom meta_query order for Elementor based on post meta key [closed]
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- ElasticPress is (aparently) messing with my search filters
- Meta query ignores multiple values of the key
- Trouble with serialized metadata
- Multiple meta_query not returning rows
- meta_query order by date present -> future then show null
- Check for not NULL not working in meta query
- Get unique post by meta value using wp_query
- Query against multiple locations within single custom post type post
- WP_Query, ACF field and array
- Order by Date Custom Field
- WP Query. Ordering posts by another post types meta
- Complex Meta Query
- Speed up WP_query with meta comparing dates
- Meta Query if Values Don’t Exist
- Saving custom fields for WP_Query to retrieve
- How to show all the associated posts with specific date of data metabox?
- Is it possible to search for a string in posts OR postmeta?
- Filter posts/pages by user_role array
- WP_Query with MetaQuery issue
- WP_Query Posts by Metadata from Option Tree
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- WP_Query with meta_value_num and meta_query not paged correctly
- Post Query not working after updating to 4.1
- Orderby Meta Value and Query from Meta Query
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Sort Posts with custom meta key by default which is currently set as optional
- Why is WP_Query’s meta_query not filtering results?
- WP_Query with several meta_query-statements and order by meta_value
- meta_query in wp_query not working as expected
- WordPress extremely slow when using get_posts with multiple meta_query relations
- Use meta query only 3 or more results?
- Use value from meta key array for use in WP_Query
- WordPress – Optimize the Meta Query for 3 meta keys at a time