bricks_get_global_queries

Phase 1BeginnerRead OnlyComplexity: 2/10
List all reusable global queries

Overview

List all saved global queries from the Bricks design system. Global queries (introduced in Bricks v2.1) are reusable query configurations stored centrally and referenced by any element with a query loop across the entire site.

Instead of configuring the same query parameters on every page, create a global query once and reference it by ID. When you update the global query, all elements referencing it automatically use the updated settings.

Key Features

Filter by Category
Narrow results to queries in a specific category for organized browsing of large query libraries.
Filter by Object Type
View only post queries, term queries, user queries, or API queries by specifying the object_type filter.
Full Configuration Visibility
Returns the complete query configuration for each global query including all parameters, filters, and ordering settings.

When to Use

Checking what global queries already exist before creating new ones
Finding the ID of a global query to reference in bricks_set_query_loop
Auditing query configurations across the site for consistency
Filtering queries by category or object type to find specific ones
Prerequisites
Bricks version 2.1 or higher (global queries feature)
At least one global query must exist (created via bricks_create_global_query)

When NOT to Use

You need to create a new global query — use bricks_create_global_query instead
You want to see the query results/data — global queries are configurations, not data
Listing queries configured inline on elements — this only shows globally saved queries

Parameters

2 Total Parameters2 Optional
categorystringoptional
Filter global queries by category name or ID.
object_typestringoptional
Filter by query object type.
Default: all Values: post, term, user, api, all

Code Examples


Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

List all post-type global queries

Retrieve only global queries that query WordPress posts/CPTs.

JSON
// Get all post queries
const queries = await bricks_get_global_queries({
  object_type: "post"
});

// Returns:
// [
//   { id: "gq_abc123", label: "Latest Blog Posts", query: { objectType: "post", post_type: "post", posts_per_page: 6 } },
//   { id: "gq_def456", label: "Featured Products", query: { objectType: "post", post_type: "product", meta_query: [...] } }
// ]

// Reference a global query in a query loop:
bricks_set_query_loop({
  page_id: 123,
  element_id: "loop-item",
  query: { useGlobalQuery: "gq_abc123" }
});

Common Mistakes


Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
This tool only returns queries saved globally via bricks_create_global_query. Queries configured directly on elements via bricks_set_query_loop are not listed here.

Tips & Warnings

Tips & Warnings

Use global queries for consistency. If the same query (e.g., « latest 6 blog posts ») appears on multiple pages, create it as a global query once and reference it everywhere.

The returned query ID is used in bricks_set_query_loop via { useGlobalQuery: "<id>" } to connect an element to the global query.

Return Values

FieldTypeDescription
queriesarrayArray of global query objects, each containing id, label, category, and query configuration.
queries[].idstringUnique ID for referencing this query via useGlobalQuery.
queries[].labelstringDisplay name of the global query.
queries[].queryobjectThe full query configuration (objectType, post_type, posts_per_page, tax_query, etc.).

Related Tools

Technical Details

Tool ID
bricks_get_global_queries
API Endpoint
/bricks-mcp/v1/design-system/global-queries
HTTP Method
GET
Namespace
content-queries
Source File
content/global-queries.ts
Version
1.0
Min Bricks Version
2.1
Requires Auth
Yes

Changelog

v1.0
Initial release with Bricks v2.1 global queries support
20250101