# SOLVED: Condition with Type true/false

**URL:** <https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225>\
**Category:** How To\
**Created:** [August 16, 2022, 9:31am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225 "2022-08-16T09:31:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![stabilo](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@stabilo](https://forum.bricksbuilder.io/u/stabilo)\
**Post date:** [August 16, 2022, 9:31am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/1 "2022-08-16T09:31:37Z")

</div>

Hello,  
I have an ACF field of type true/false (trainer\_verification).  
 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/f/f67e094722301027ef209a0d37b2b9515b0fb15d.png)

I have an element (icon + text) with a class “tp-verification”.  
 ![image](https://forum.bricksbuilder.io/uploads/default/original/2X/1/11d1190bb2e95f9e17a1d5165f41404a6d143307.png)

I want to show the element with class tp-verification only if the trainer\_verification field is true.

Can someone please help me? I tried this tutorial: [[SOLVED] ACF Repeater + Condition | Show/Hide Bricks Element if ACF Button Group is yes or no](https://forum.bricksbuilder.io/t/solved-acf-repeater-condition-show-hide-bricks-element-if-acf-button-group-is-yes-or-no/4493)  
Unfortunately, I can’t get it to work.

---

<div class="post-metadata">

**Author:** ![Sridhar](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/sridhar/32/22855_2.png) [@Sridhar](https://forum.bricksbuilder.io/u/Sridhar)\
**Post date:** [August 17, 2022, 6:47am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/2 "2022-08-17T06:47:58Z")

</div>

Hi,

What is the location setting for your field group? Pages or Posts or somewhere else?

and where is your icon + text element located?

---

<div class="post-metadata">

**Author:** ![stabilo](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@stabilo](https://forum.bricksbuilder.io/u/stabilo)\
**Post date:** [August 17, 2022, 7:15am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/3 "2022-08-17T07:15:40Z")

</div>

I’m using Custom Post Type named “Personal Trainer”.

 ![grafik](https://forum.bricksbuilder.io/uploads/default/original/2X/6/651ec365f0d63acacd94f57ae11b5bbe6415f511.png)

Icon + Text-Element is in Bricks Template of Archive-Type:

 ![grafik](https://forum.bricksbuilder.io/uploads/default/original/2X/1/1eb110db60856be41866c951337ecf69a34023f5.png)

(but i need the condition also for “personal-trainer” Bricks-Template of single-type. See picture above.)

---

<div class="post-metadata">

**Author:** ![Sridhar](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/sridhar/32/22855_2.png) [@Sridhar](https://forum.bricksbuilder.io/u/Sridhar)\
**Post date:** [August 17, 2022, 8:54am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/4 "2022-08-17T08:54:17Z")

</div>

Here’s sample code:

```auto
// 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.

---

<div class="post-metadata">

**Author:** ![stabilo](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@stabilo](https://forum.bricksbuilder.io/u/stabilo)\
**Post date:** [August 17, 2022, 9:14am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/5 "2022-08-17T09:14:43Z")

</div>

Thank you. But it don’t work for me.

```auto
// 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( 'pt-verification', $classes ) ) {
		return get_post_meta( get_the_ID(), 'trainer_verifizierung', true );
	}

	return $render;
  }, 10, 2 );

```

The Content with class “pt-verification” are always shown and never hidden. I also clear cache etc.

---

<div class="post-metadata">

**Author:** ![Sridhar](https://forum.bricksbuilder.io/user_avatar/forum.bricksbuilder.io/sridhar/32/22855_2.png) [@Sridhar](https://forum.bricksbuilder.io/u/Sridhar)\
**Post date:** [August 17, 2022, 9:16am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/6 "2022-08-17T09:16:37Z")

</div>

> [@stabilo](#):
>
> `if ( 'service' !== get_post_type() ) {`

You need to replace `service` in that line with your CPT’s identifier.

---

<div class="post-metadata">

**Author:** ![stabilo](https://forum.bricksbuilder.io/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@stabilo](https://forum.bricksbuilder.io/u/stabilo)\
**Post date:** [August 17, 2022, 9:23am UTC](https://forum.bricksbuilder.io/t/solved-condition-with-type-true-false/5225/7 "2022-08-17T09:23:33Z")

</div>

Ah! Ups. Sorry. Now it works 🙂 Thanks a lot Sridhar!
