bricks_get_custom_code

Phase 1BeginnerRead OnlyComplexity: 2/10
Read global custom CSS and JavaScript

Overview

Reads the custom CSS and JavaScript code from a page or from the global site settings. Returns the code stored in customCss, customScriptsHeader, customScriptsBodyHeader, and customScriptsBodyFooter. Useful for inspecting what custom code is already in place before modifying.

Key Features

Dual scope
Read custom code from global site settings or from a specific page
All code slots
Returns CSS, header scripts, body header scripts, and body footer scripts

When to Use

Before adding custom CSS/JS to check what already exists
Debugging styling or script issues
Verifying CDN libraries were properly injected
Inspecting page-specific vs global custom code
Prerequisites
No prerequisites for global scope
For page scope, you need the page_id

When NOT to Use

To modify custom code — use bricks_add_custom_css or bricks_add_custom_js instead
To read page element content — use bricks_get_page_content instead

Parameters

2 Total Parameters1 Required1 Optional
scopeenumREQUIRED
Where to read from: "global" for site-wide, "page" for a specific page
Values: global, page
page_idnumberoptional
Page ID (required when scope is "page")

Code Examples

Read global custom code

Check what custom CSS and JS is already loaded globally

JSON
{
    "scope": "global"
}
Response
{"customCss": ".hero { background: ... }", "customScriptsHeader": "<link ...>", "customScriptsBodyFooter": "<script src=...>"}

Common Mistakes

Not checking existing code before appending
Always read existing code first to avoid duplicating CDN library tags or CSS rules

Tips & Warnings

Tips & Warnings
  • Bricks stores custom code in bricks_global_settings option (global) or BRICKS_DB_PAGE_SETTINGS post meta (page)
  • Always check existing code before adding more to avoid duplicates

Return Values

FieldTypeDescription
customCssstringCustom CSS code
customScriptsHeaderstringScripts injected in the <head>
customScriptsBodyFooterstringScripts injected before </body>

Related Tools

Technical Details

Tool ID
bricks_get_custom_code
API Endpoint
/bricks-mcp/v1/custom-code
HTTP Method
GET
Namespace
wordpress-site
Source File
wordpress/custom-code.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101