{
  "name": "bricks/element/render",
  "kind": "filter",
  "url": "https://academy.bricksbuilder.io/developer/hooks/filters/filter-bricks-element-render/",
  "scraped_at": "2026-08-29",
  "hook_name": "bricks/element/render",
  "description": {
    "en": "Bricks 1.5 introduces the new bricks/element/render filter. This filter enables you to implement your own conditional display logic programmatically. This is ideal for restricting premium content to certain users, etc. If the condition inside this filter is not met (i.e. it returns false ), then the element won’t be rendered on the frontend. In the following example, we check if the element has a specific element ID, and if so, we allow the element to be rendered based on the logged-in/out condition. The following example will render an element if it contains the custom CSS class hide-for-subscribers , if the user is logged in and is not a subscriber. You may select different users’ capabilities according to your needs. The following example will render a specific element based on the HTML ID on a single post page with a specific category: The following example renders elements that have a class of logged-in only to users that are logged in and elements that have a class of logged-out only to users that are logged out: The following example renders an element that has the specified HTML ID based on the value of a specific custom field of the current post when viewing a singular page: The examples above are really just to illustrate a few simple use cases. Anything that you can check with PHP is possible to include in your own conditional display logic using this new bricks/element/render filter. Scenario: ACF Repeater: FAQs Sub fields: Question, Answer, Button Text and Button URL Requirement: When Query Loop’s query type is set to this ACF Repeater, output a Button (a child element of the repeating element) only in the rows that have a value set for the Button Text sub field. where huciku is the element ID of the Button. Note: This will be applied as brxe-huciku class in the output in this case, not a ID. Also, replace faqs and button_text strings as applicable.",
    "zh": "使用此筛选器可自定义 WooCommerce 元素的设置与渲染逻辑。"
  },
  "example_usage": "// Output one or more instances of the specified element (inside a query loop of ACF Repeater type) when the condition is true.\n// Condition: The specified sub field inside the specified ACF Repeater field is not empty.\nadd_filter( 'bricks/element/render', function( $render, $element ) {\n  if ( $element->id === 'huciku' && class_exists( 'ACF' ) ) {\n    if ( have_rows( 'faqs' ) ) {\n      // Loop through rows.\n      while( have_rows( 'faqs' ) ) : the_row();\n        return get_sub_field( 'button_text' );\n      // End loop.\n      endwhile;\n    }\n  }\n\n\n  return $render;\n}, 10, 2 );"
}