用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/wpgaurav/WordPress-skills --skill bricks-templates命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Author Bricks Builder (WordPress) layouts, templates, and full designs as paste-ready JSON. Use for any Bricks task — sections, pages, headers/footers, query loops, ACF/dynamic data, faceted filters, conditions, interactions/animations, popups, WooCommerce templates, custom elements, or hooks. Verified against Bricks 2.3.6 source.
Use when pushing content, docs, posts, changelogs, or other updates to Fluent Community spaces through the Fluent Community REST API.
Generate or edit design for WordPress Gutenberg blocks using Greenshift/GreenLight plugin. Convert any data to wordpress blocks or convert greenshift blocks back to html + css + js. Use when user asks to create design with Greenshift or Greenlight blocks for wordpress site, convert anything to wordpress blocks or build charts in content. Triggers on keywords: wordpress, gutenberg, greenshift, greenlight, convert to wordpress, convert greenshift blocks to vanilla html, build chart.
基于 SOC 职业分类
正在显示 SKILL.md
| name | bricks-templates |
| description | Create and work with Bricks templates programmatically. |
This skill covers creating and working with Bricks templates programmatically.
Bricks supports these template types (stored in _bricks_template_type meta):
| Type | Purpose | Meta Key for Content |
|---|---|---|
header | Site header | _bricks_page_header_2 |
footer | Site footer | _bricks_page_footer_2 |
content | Single post/page content | _bricks_page_content_2 |
section | Reusable section | _bricks_page_content_2 |
archive | Archive pages | _bricks_page_content_2 |
search | Search results | _bricks_page_content_2 |
error | 404 error page | _bricks_page_content_2 |
popup | Popup/modal | _bricks_page_content_2 |
password_protection | Password protected content | _bricks_page_content_2 |
// Post type slug
BRICKS_DB_TEMPLATE_SLUG = 'bricks_template'
// Taxonomies
BRICKS_DB_TEMPLATE_TAX_TAG = 'template_tag'
BRICKS_DB_TEMPLATE_TAX_BUNDLE = 'template_bundle'
/**
* Create a Bricks template programmatically
*/
function create_bricks_template( $title, $type, $elements = [] ) {
// Create the template post
$template_id = wp_insert_post( [
'post_title' => $title,
'post_type' => BRICKS_DB_TEMPLATE_SLUG,
'post_status' => 'publish',
] );
if ( is_wp_error( $template_id ) ) {
return $template_id;
}
// Set template type
update_post_meta( $template_id, BRICKS_DB_TEMPLATE_TYPE, $type );
// Set template content based on type
$meta_key = BRICKS_DB_PAGE_CONTENT;
if ( $type === 'header' ) {
$meta_key = BRICKS_DB_PAGE_HEADER;
} elseif ( $type === 'footer' ) {
$meta_key = BRICKS_DB_PAGE_FOOTER;
}
if ( ! empty( $elements ) ) {
update_post_meta( $template_id, $meta_key, $elements );
}
return $template_id;
}
Templates store elements as arrays with this structure:
$elements = [
[
'id' => 'abc123', // 6-character alphanumeric ID
'name' => 'section',
'parent' => 0, // 0 for root, or parent element ID
'children' => [ 'def456' ], // Child element IDs
'settings' => [
// Element-specific settings
],
],
[
'id' => 'def456',
'name' => 'heading',
'parent' => 'abc123',
'children' => [],
'settings' => [
'text' => 'Hello World',
'tag' => 'h1',
],
],
];
function create_header_template() {
$elements = [
[
'id' => Bricks\Helpers::generate_random_id( false ),
'name' => 'section',
'parent' => 0,
'children' => [],
'settings' => [
'tag' => 'header',
'_padding' => [
'top' => '20px',
'right' => '40px',
'bottom' => '20px',
'left' => '40px',
],
],
],
];
return create_bricks_template( 'My Header', 'header', $elements );
}
Templates use conditions to determine when they apply. Set via _bricks_template_settings meta:
$template_settings = [
'templateConditions' => [
[
'main' => 'postType',
'sub' => 'post',
'compare' => '==',
],
],
];
update_post_meta( $template_id, BRICKS_DB_TEMPLATE_SETTINGS, $template_settings );
| Main | Sub Options | Description |
|---|---|---|
entireWebsite | - | Applies everywhere |
frontpage | - | Front page only |
postType | post, page, {cpt} | Specific post type |
archiveType | author, date, post_tag, category | Archive pages |
searchResults | - | Search results page |
error | - | 404 page |
// In PHP
echo do_shortcode( '[bricks_template id="123"]' );
// In Bricks element
// Use the Template element and select the template
// Get template elements
$elements = get_post_meta( $template_id, BRICKS_DB_PAGE_CONTENT, true );
// Render elements
if ( ! empty( $elements ) && is_array( $elements ) ) {
echo \Bricks\Frontend::render_data( $elements );
}
REST API namespace: bricks/v1/
| Endpoint | Method | Purpose |
|---|---|---|
/get-templates/ | GET | Get all templates |
/get-templates/{id} | GET | Get specific template |
/get-templates-data/ | GET | Get templates with metadata |
/get-template-authors/ | GET | Get template authors |
/get-template-bundles/ | GET | Get template bundles |
/get-template-tags/ | GET | Get template tags |
// Get template type
$type = \Bricks\Templates::get_template_type( $template_id );
// Get templates by type
$templates = \Bricks\Templates::get_templates_by_type( 'section' );
// Get templates list for select control
$list = \Bricks\Templates::get_templates_list( ['section', 'content'] );
// Check if post is a Bricks template
$is_template = \Bricks\Helpers::is_bricks_template( $post_id );
Enable remote template access in settings, then query from other sites:
// Settings to enable
// Bricks > Settings > Templates
// - Enable "My Templates Access"
// - Optionally set whitelist URLs
// - Optionally set password
Templates can be exported as JSON:
// Export structure
$export = [
'content' => $elements,
'templateType' => $type,
'globalClasses' => $classes,
'globalElements' => $global_elements,
];
// Modify templates data from API
add_filter( 'bricks/api/get_templates_data', function( $templates_data ) {
// Modify templates data
return $templates_data;
} );
// Control template access
add_filter( 'bricks/get_templates', function( $templates, $args ) {
// Filter templates based on $args['site'], $args['licenseKey'], etc.
return $templates;
}, 10, 2 );
// After template import
add_action( 'bricks/template/after_import', function( $template_id, $data ) {
// Process imported template
}, 10, 2 );
\Bricks\Helpers::generate_random_id( false ) for element IDs