Display an element conditionally based on content in the options_meta table, referencing an ACF field.
I’ve created a Theme Options ACF Options Page, which stores its field data in the options table. I need to conditionally display an element in a global Header Template based on the content of that field. I think I’m close, but not quite.
Working of of example 5 on the Filter:Render page:
add_filter( 'bricks/element/render', function( $render, $element )
// Get the element custom HTML ID
$html_id = isset( $element->settings['_cssId'] ) ? $element->settings['_cssId'] : false;
//Check if the element has the HTML ID "header-primary-button"
if ( $html_id && $html_id === 'header-primary-button' ) {
return ! get_option('options_add_primary_cta_button', false); }
return $render; }, 10, 2 );
I know I’m close, but it’s not quite right. The option is correctly stored in the database, but I don’t think I’m evaluating it correctly.