{
  "name": "bricks/active_templates",
  "kind": "filter",
  "url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-active_templates/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks/active_templates",
  "description": {
    "en": "Modify the templates applied on a page programmatically ( @since 1.8.4 ) This is an alternative to setting an active template via the bricks/screen_conditions/scores filter. In this example, we want to exclude the single post from utilizing a template if it contains Bricks data (Edit with Bricks). There is a scenario like having multiple single templates for a custom post type. Using this filter, you can decide which template to apply based on a custom field. Since Bricks 1.12, templates applied to a page are now also displayed in the Builder. Previously, only the Post Content element was visible, making it difficult to style surrounding elements. If you prefer the old behavior and want to disable the applied template only inside the builder , you can use this filter:",
    "zh": "以编程方式修改应用于页面的模板（@since 1.8.4）。这是通过 bricks/screen_conditions/scores 筛选器设置激活模板的替代方式。在下例中，我们希望在 Bricks 数据（使用 Bricks 编辑）的单篇文章中排除使用模板。还有一种场景是自定义文章类型存在多个单篇模板。通过此筛选器，你可以基于自定义字段决定使用哪个模板。从 Bricks 1.12 起，应用于页面的模板也会显示在构建器中。之前只能看到 Post Content 元素，难以对周围元素进行样式化。如果你想保留旧行为，并仅在构建器内禁用已应用模板，可使用此筛选器："
  },
  "example_usage": "add_filter( 'bricks/active_templates', 'disable_template_in_builder', 10, 3 );\n\n\nfunction disable_template_in_builder( $active_templates, $post_id, $content_type ) {\n  // Only run my logic in the Builder\n  if ( bricks_is_builder() ) {\n    $active_templates['content'] = 0;\n  }\n\n\n  return $active_templates;\n}"
}