{
  "name": "bricks/query_api/total_pages",
  "kind": "filter",
  "url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-query_api-total_pages/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks/query_api/total_pages",
  "description": {
    "en": "Filters the total number of pages calculated for an external API query loop. This is useful when the API response structure for pagination doesn’t match Bricks’ standard extraction logic.",
    "zh": "筛选为外部 API 查询循环计算的总页数。当 API 响应的分页结构与 Bricks 的标准提取逻辑不匹配时，这很有用。"
  },
  "parameters": [
    {
      "name": "total_pages",
      "type": "int",
      "type_zh": null,
      "description": {
        "en": "The calculated total number of pages.",
        "zh": "已计算的总页数。"
      }
    },
    {
      "name": "element_id",
      "type": "string",
      "type_zh": null,
      "description": {
        "en": "The ID of the query element.",
        "zh": "查询元素的 ID。"
      }
    },
    {
      "name": "query_api",
      "type": "object",
      "type_zh": null,
      "description": {
        "en": "The Bricks\\Integrations\\Query\\Query_API instance.",
        "zh": "Bricks\\Integrations\\Query\\Query_API 实例。"
      }
    }
  ],
  "example_usage": "add_filter( 'bricks/query_api/total_pages', function( $total_pages, $element_id, $query_api ) {\n    // Example: Set total pages for a specific API query\n    if ( $element_id === 'my_api_loop' ) {\n        // Assume you stored the total in a custom property or need a fixed value\n        return 10;\n    }\n\n\n    return $total_pages;\n}, 10, 3 );"
}