📄 原始资料 | 展开查看原始 JSON(bricks-render_with_bricks.json){ “name”: “bricks/render_with_bricks”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-render_with_bricks/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/render_with_bricks”, “description”: …
📄 原始资料 | 展开查看原始 JSON(bricks-render_with_bricks.json)
{
"name": "bricks/render_with_bricks",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-render_with_bricks/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/render_with_bricks",
"description": {
"en": "Determines whether a specific post or page should be rendered using Bricks. If this filter returns false , Bricks will yield control to the default WordPress template loader or another builder.",
"zh": "确定是否应使用 Bricks 渲染特定文章或页面。如果此筛选器返回 false,Bricks 将控制权交给默认的 WordPress 模板加载器或其它构建器。"
},
"parameters": [
{
"name": "render",
"type": "bool|null",
"type_zh": null,
"description": {
"en": "Whether to render with Bricks. Default is null (Bricks decides based on settings).",
"zh": "是否使用 Bricks 渲染。默认为 null(Bricks 根据设置决定)。"
}
},
{
"name": "post_id",
"type": "int",
"type_zh": null,
"description": {
"en": "The ID of the post being checked.",
"zh": "正在被检查的文章 ID。"
}
}
],
"example_usage": "add_filter( 'bricks/render_with_bricks', function( $render, $post_id ) {\n // Example: Disable Bricks rendering for posts with a specific meta value\n if ( get_post_meta( $post_id, 'disable_bricks', true ) ) {\n return false;\n }\n\n\n return $render;\n}, 10, 2 );"
}
前言
确定是否应使用 Bricks 渲染特定文章或页面。如果此筛选器返回 false,Bricks 将控制权交给默认的 WordPress 模板加载器或其它构建器。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/render_with_bricks', function( $render, $post_id ) {
// Example: Disable Bricks rendering for posts with a specific meta value
if ( get_post_meta( $post_id, 'disable_bricks', true ) ) {
return false;
}
return $render;
}, 10, 2 );
参数
$render (bool|null):是否使用 Bricks 渲染。默认为 null(Bricks 根据设置决定)。
$post_id (int):正在被检查的文章 ID。
示例代码
筛选返回值
add_filter( 'bricks/render_with_bricks', function( $render, $post_id ) {
// Example: Disable Bricks rendering for posts with a specific meta value
if ( get_post_meta( $post_id, 'disable_bricks', true ) ) {
return false;
}
return $render;
}, 10, 2 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/render_with_bricks', function( $value, $render ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。