Home Forums Front-end Issues True / False feild – return label if true


True / False feild – return label if true

  • Hi,

    I’m trying to create a simple ‘Featured’ label based off true / false advanced custom field.

    In the property post type, if the product is featured you tick the box, and it will show a label badge, if it’s not featured you leave it unticked by default and nothing appears.

    Custom field is true / false – field name $featured_property

    Here is the frontend labels.


    I tried this.. but failed

    <?php $true = get_post_meta( get_the_ID(), 'featured_property', true ); ?>
            if ( $true == '1' ) {
        <span class="property-badge">Featured</span>

    Any tips please for a newb!

  • You can try:
    <?php if ( get_field( 'featured_property' ) ): ?><span class="property-badge">Featured</span><?php endif; ?>

    <?php if ( get_field( 'featured_property', get_the_ID() ) ): ?><span class="property-badge">Featured</span><?php endif; ?>

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.