Support

Account

Home Forums Backend Issues (wp-admin) if function is not working in archeive. php file

Solved

if function is not working in archeive. php file

  • <?php

    if(get_field(‘select_the_value’) == ‘TRUE’)
    {
    the_field( ‘select_the_country’, $queried_object );
    }
    else
    {
    the_field( ‘select_the_city’, $queried_object );
    }
    ?>

    i try to get the value as true
    if its true it has to display about the country details
    if its false means it has to display the city details

    plzzzzzzzzzzzzzzzzz help me to find the solution

  • 1. If select_the_value is a true/false field, it will already return true/false, so if(get_field('select_the_value')) should be enough.
    2. If select_the_value is another kind of field (e.g. checkbox or select), 'TRUE' must be defined as a field option (ergo be a string), otherwise it won’t match

    In other words, this might work like this:

    
    $fieldName = get_field('select_the_value') ? 'select_the_country' : 'select_the_city';
    the_field($fieldName, $queried_object);
    
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘if function is not working in archeive. php file’ is closed to new replies.