Links

Meta Filters (Pro)

Meta filters allows you to filter by field, and create complex queries with multiple fields.

Step by step

  1. 1.
    Create your Card and assign a View as usual. (See Creating an ACF Card).
  2. 2.
    Switch to the Meta Filters tab.
  3. 3.
    Click on the ‘Add Rule’ button.
  4. 4.
    Click on the ‘Add Field’ button.
  5. 5.
    In the Group field select the field group.
  6. 6.
    Select the Field from the dropdown.
  7. 7.
    For the Comparison field, select how you would like to compare the fields.
  8. 8.
    Enter a Value that will be compared.
  9. 9.
    Repeat steps 4 to 8 to add more fields.
  10. 10.
    Click ‘Update’ to save your Card.
Note: adding another Rule (see step 3) will create a relation to control how field rules will be joined within the meta query.
Note: Do you want to customize a query (WP_Query) that is used to get posts for a Card, but the option is missing in the UI? You can do this using our filters. Read more here​

Watch the video

Query for relationship/post_object fields

In the Meta Filters tab you can set the relationship and post_object fields.
For Example:
Let’s imagine that you have a Company and Employee CPT. Every Employee has a post_object field, where the current Company of the Employee is selected.
Our goal is to create a Card for Company CPT, which will display all Employees of the current Company.

Step by step

  1. 1.
    Create (or open) an ACF Card, which will query posts by the relationship/post_object field.
  2. 2.
    Create a new Meta Rule and select the target relationship/post_object field. Choose ‘Equal’ in the Comparison setting.
  3. 3.
    Define a value, which can be done in a couple of ways; a) Use the special $post$ value if you’re going to paste a Card shortcode on a Page or Post, of which the ID should be used in the meta_query. It means the $post$ will be replaced with an ID of the Post, where you’ve pasted the shortcode, and the query will find all Posts, where the relationship/post_object field of the current post ID is chosen. In our Company example this fits perfectly well and can be used to display all Employees on the Company CPT. b) Numeric ID of the target Post. If you want to query all posts which have the specific Post selected in their relationship/post_object field, but this specific Post is different from the Page where you’re going to paste the shortcode, then you must define a numeric ID of that specific Post. In our Company example this can be used to display all Employees for the specific Company CPT on the homepage or another page.
  4. 4.
    Save the ACF Card, and paste the Card shortcode in the target place.
  5. 5.
    That’s it, you’re done.