Bricks 中文文档:bricks/posts/query_vars

标签TAGS: 

📄 原始资料  |  展开查看原始 JSON(bricks-posts-query_vars.json){ “name”: “bricks/posts/query_vars”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-posts-query_vars/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/posts/query_vars”, “description”: {…

📄 原始资料  |  展开查看原始 JSON(bricks-posts-query_vars.json)
{
  "name": "bricks/posts/query_vars",
  "kind": "filter",
  "url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-posts-query_vars/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks/posts/query_vars",
  "description": {
    "en": "Since Bricks 1.3.2 you may manipulate the posts , products, or Query Loop elements query vars before the query is performed like so: The filter callback receives three arguments: If you want to build a dynamic Slider in term archive template, you can set the query loop on the Slide like below image, and use the code snippet below to retrieve the images IDs from the gallery field for each term, then assign them to the post__in parameter. Imagine you got a Performance post type with a start date field and a start time field. As you will not create the Performance post by actual sequence, you wish to order the Performance posts by start date (ascending) and start time (descending). Since 1.11.1, you can achieve this in Query Loop user interface. Check this out. Create a query loop with the following settings Create a query loop with the following settings: Sometimes you might want to target a group of queries instead of a specific element by using the $element_id",
    "zh": "从 Bricks 1.3.2 起,你可以在执行查询之前操纵 posts、products 或 Query Loop 元素的查询变量,如下所示:筛选器回调接收三个参数:如果你想在 term archive 模板中构建动态 Slider,可以按下方图片在 Slide 上设置查询循环,并使用下方代码片段从 gallery 字段中检索每个 term 的图像 ID,然后将其分配给 post__in 参数。假设你有一个 Performance 文章类型,包含开始日期字段和开始时间字段。由于你不会按实际顺序创建 Performance 文章,你希望按开始日期(升序)和开始时间(降序)对 Performance 文章进行排序。从 1.11.1 起,你可以在 Query Loop 用户界面中实现这一点。创建一个具有以下设置的查询循环:创建一个具有以下设置的查询循环:有时你可能希望使用 $element_id 来定位一组查询而不是特定元素。"
  },
  "example_usage": null
}

前言

从 Bricks 1.3.2 起,你可以在执行查询之前操纵 posts、products 或 Query Loop 元素的查询变量,如下所示:筛选器回调接收三个参数:如果你想在 term archive 模板中构建动态 Slider,可以按下方图片在 Slide 上设置查询循环,并使用下方代码片段从 gallery 字段中检索每个 term 的图像 ID,然后将其分配给 post__in 参数。假设你有一个 Performance 文章类型,包含开始日期字段和开始时间字段。由于你不会按实际顺序创建 Performance 文章,你希望按开始日期(升序)和开始时间(降序)对 Performance 文章进行排序。从 1.11.1 起,你可以在 Query Loop 用户界面中实现这一点。创建一个具有以下设置的查询循环:创建一个具有以下设置的查询循环:有时你可能希望使用 $element_id 来定位一组查询而不是特定元素。

补充说明

更多细节可参考 官方文档