Links

Dynamic Injection

The value field in the Meta Filter supports dynamic injection. This means you don’t need to use only static values, but have the option to also define page id/field and datetime aliases. These aliases will be replaced dynamically with the current value depending on the page and/or current date and time respectively.
Get current post ID
Note: $post$ will be replaced with the current post id.
Example usage: find all posts where post_object/relationship field contains the current page in the list.
Compare current post with field value
To compare with a field value, you can use $post$.field-name, where 'field-name' should be replaced with the name of your target field. In this way, the plugin will automatically get and use a value of the field from the current page in the query.
Example usage: find all posts where a 'select' field has the same option chosen, as the option chosen on the current page.
Compare date to current date and time
To compare the value in an ACF Date or an ACF Date/Time field to the current date and time.
Note: $now$ will be replaced with the current date and time the page is viewed.
Example usage: find all posts where 'date' field value is "Bigger than" current date and time. So as to show only upcoming events in the posts grid or list.

Extended support for Post_object and Relationship fields

Advanced Views Pro supports Post_object and Relationship field types in the Meta filters.

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 guide

Create a View, then add the fields of your Employees CPT.
Next, Create or edit a Card, which will query posts by the relationship/post_object field.
Switch to the Meta Filters tab.
Click on the Add Rule button and then Add Field button to create a new Meta Rule, then select the target relationship/post_object field.
Choose Equal to in the Comparison setting.
Define a value, which can be done in a couple of ways.
  1. 1.
    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. This 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.
  2. 2.
    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.
  3. 3.
    Use the relation field alias i.e. $post$.your-field to find all posts that have the same option selected as the current page. Note: if the current page field contains multiple values, then it will get pages, where at least one matches.
Save the Card, and paste the Card shortcode in the target place.
That’s it, you’re done.
Behind the scenes, it does the necessary trick of wrapping into quotes and using 'Like' for comparison, so you won't need to take care of it. It'll work with all the field options for Single, Multiple select and all return formats of a field.