This section appears for post/term/user queries, and it is helpful to restrict your query using custom field values. See WP Documentation.
- Relation: Relation for the taxonomy query. Use AND if you want all conditions to be true to select the post, OR if you only need one condition to be true.
- Custom Field Type: Select the custom field type.
- Operator: Operator to use to compare the custom field value(s).
- Custom Field Name: Name of the custom field.
- Custom Field Value: Comma-separate string of values. These values will be checked using the operator for each post.
You can create multiple groups of custom field comparisons to satisfy the condition that determines which posts to display.
Let’s say that, for example, you want to show posts that have a value ‘hello’ on a custom field called ‘acf_text’ and a value 4 on a custom field called ‘number’. For this use case, you will select the AND relation, and create two groups of conditions, one for acf_text EQUAL ‘hello’ and another for number EQUAL 4.
For DATE and DATETIME field types, you can use any valid strtotime string, such as ‘now’, to compare against the current date. Documentation.
2 Comments
Submit a Comment
You must be logged in to post a comment.
For a non-required ACF Date field, what would your query be like to identify posts where the date field was empty?
Hi David
To get the results of posts that either don’t have the ACF Date field defined or have it defined but with an empty value, you will need to add two meta queries on our plugin, one with operator NOT EXISTS and an empty value, and another with operator equal and also an empty value.
Open a ticket here https://divicoding.com/support/, and we will send you detailed instructions.