📄 原始资料 | 展开查看原始 JSON(bricks-metabox-show_as_map.json){ “name”: “bricks/metabox/show_as_map”, “kind”: “filter”, “url”: “https://academy.bricksbuilder.io/developer/hooks/filters/bricks-metabox-show_as_map/”, “scraped_at”: “2026-08-29”, “hook_name”: “bricks/metabox/show_as_map”, “descriptio…
📄 原始资料 | 展开查看原始 JSON(bricks-metabox-show_as_map.json)
{
"name": "bricks/metabox/show_as_map",
"kind": "filter",
"url": "https://academy.bricksbuilder.io/developer/hooks/filters/bricks-metabox-show_as_map/",
"scraped_at": "2026-08-29",
"hook_name": "bricks/metabox/show_as_map",
"description": {
"en": "Determines whether a Meta Box map field should be rendered as a map (using rwmb_meta() ) or as raw latitude/longitude coordinates when used in dynamic data.",
"zh": "此筛选器允许你修改 Bricks 中已注册的页面设置默认值。"
},
"parameters": [
{
"name": "show_as_map",
"type": "bool",
"type_zh": null,
"description": {
"en": "Whether to render as a map. Default is false (renders coordinates).",
"zh": "是否渲染为地图。默认为 false(渲染坐标)。"
}
},
{
"name": "field",
"type": "array",
"type_zh": null,
"description": {
"en": "The Meta Box field settings array.",
"zh": "Meta Box 字段设置数组。"
}
},
{
"name": "post",
"type": "WP_Post",
"type_zh": null,
"description": {
"en": "The current post object.",
"zh": "当前文章对象。"
}
}
],
"example_usage": "add_filter( 'bricks/metabox/show_as_map', function( $show_as_map, $field, $post ) {\n // Example: Render as map for a specific field ID\n if ( $field['id'] === 'my_map_field' ) {\n return true;\n }\n\n\n return $show_as_map;\n}, 10, 3 );"
}
前言
此筛选器允许你修改 Bricks 中已注册的页面设置默认值。
用法
将代码加入子主题的 functions.php:
add_filter( 'bricks/metabox/show_as_map', function( $show_as_map, $field, $post ) {
// Example: Render as map for a specific field ID
if ( $field['id'] === 'my_map_field' ) {
return true;
}
return $show_as_map;
}, 10, 3 );
参数
$show_as_map (bool):是否渲染为地图。默认为 false(渲染坐标)。
$field (array):Meta Box 字段设置数组。
$post (WP_Post):当前文章对象。
示例代码
筛选返回值
add_filter( 'bricks/metabox/show_as_map', function( $show_as_map, $field, $post ) {
// Example: Render as map for a specific field ID
if ( $field['id'] === 'my_map_field' ) {
return true;
}
return $show_as_map;
}, 10, 3 );
根据条件短路返回原值
根据条件跳过或修改返回值:
add_filter( 'bricks/metabox/show_as_map', function( $value, $show_as_map ) {
if ( is_admin() ) { return $value; }
// TODO: custom logic here
return $value;
} );
补充说明
更多细节可参考 官方文档。