SOLVED: Condition with Type true/false

Here’s sample code:

// Render elements on service CPT pages having a class of "featured-service" only if the corresponding custom field's value is true.
add_filter( 'bricks/element/render', function( $render, $element ) {
	// ensure that we are on a single page of service CPT or in the service CPT's loop if on an archive
	if ( 'service' !== get_post_type() ) {
		return $render;
	}

	// get the element CSS classes
	$classes = ! empty( $element->attributes['_root']['class'] ) ? $element->attributes['_root']['class'] : false;

	if ( $classes && in_array( 'featured-service', $classes ) ) {
		return get_post_meta( get_the_ID(), 'featured_service', true );
	}

	return $render;
  }, 10, 2 );

Replace featured_service with the name of your custom field and other strings as needed.

1 Like