Using Expressions in Query Loops
Vector Expressions is fully compatible with the Query Loop block. Any block nested inside a Query Loop automatically resolves expressions against the current iteration’s post context — not the parent page.
How the Loop Context Works
When WordPress renders a Query Loop, each inner block iteration has a $block->context object containing the postId of the current post. Vector Expressions detects this context and automatically binds the post data root to the correct post for each iteration.
You do not need to do anything special — just write your expressions normally and they will always resolve to the correct post.
Example: Dynamic Post Cards
Imagine a Query Loop containing a Group block with:
- A Paragraph block bound to:
{{ post.author_name | upper }} • {{ post.date | date "F j, Y" }} - A List block with your custom meta fields
{{post.meta.amenity}} - A Group block with Class Injection:
{{ post.meta.card_type | match event="card--event" course="card--course" default="card--standard" }}
Every card in the loop will render with its own correct data automatically.
Accessing Custom Fields Per Post
Use post.meta.* to access custom fields for each post in the loop:
{{ post.meta.price | default "Contact for pricing" }}
{{ post.meta.badge_label | if then="{post.meta.is_featured}" }}
Performance in Query Loops
Expression ASTs are cached by hash. If the same expression appears on every card (which is typical), it is parsed once and the cached AST is reused for every iteration. Only the resolved values differ per post.