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
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
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
To read page element content — use bricks_get_page_content instead
Parameters
2 Total Parameters1 Required1 Optional
scopeenumREQUIREDWhere to read from: "global" for site-wide, "page" for a specific page
Values:
global, pagepage_idnumberoptionalPage 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_settingsoption (global) orBRICKS_DB_PAGE_SETTINGSpost meta (page) - Always check existing code before adding more to avoid duplicates
Return Values
Related Tools
Technical Details
Changelog
v1.0
Initial release
20250101