How to filter posts by meta fields
In Advanced Views Pro, Post Selections support meta filters and allow you to create complex queries with multiple fields.
1. How to filter posts by meta fields
Create your Post Selection and assign a Layout as usual.
Switch to the Meta Filters tab.
Click on the Add Rule button.
Click on the Add Field button.
In the Group field select the field group.
Select the Field from the dropdown.
For the Comparison field, select how you would like to compare the fields.
Type the target value literally in the Value field or choose any reserved for dynamic injection.
Click Update to save your Post Selection.
2. Dynamic Injection feature
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.
All dynamic values are wrapped with the dollar $ sign, so you can easily distinguish them.
2.1) Current post ID - $post$
$post$ value will be dynamically replaced with the current post ID.
Example usage: find all posts where the post_object/relationship field contains the current page in the list.
2.2) Current post field - $post$.*
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.
2.3) Current date/time - $now$
Use $now$t to compare the value in a Date/Time field to the current date and time. It will be replaced with the current date and time the page is viewed.
You can also add or remove periods. For example, you can use '$now$ + 1 day' or '$now$ - 1 week'. The following period keys are supported: minute, hour, day, week and month.
Example usage: find all posts where 'date' field value is "Bigger than" the current date and time. So as to show only upcoming events in the posts grid or list.
2.4) Current query ($_GET) argument - $query$.*
To compare with a query ($_GET) value, you can use $query$.field-name, where 'field-name' should be replaced with the name of your target query argument. In this way, the plugin will automatically get and use a value of the query (url) from the current page in the posts query.
2.5) Shortcode argument - $custom-arguments$.*
You can also insert a custom argument from the shortcode into the query, making the Post Selection context-dependent. Use $custom-arguments$.field-name to dynamically get the shortcode argument. This allows you to copy the Post Selection shortcode to different places and use different values, like this:
Note: This method is useful for manually defined cases. If you need to pick it up from the current page metadata, use the $post$ constant described above.
Last updated