WordPress.org

Support

Support » Plugins and Hacks » Advanced Custom Fields | if ifelse else statements

Advanced Custom Fields | if ifelse else statements

  • Hi there, I’m just getting started with ACF and writing php statements. Although I’ve been working with them for a little while I’m still building confidence.

    My aim

    To display a block of code if a radio value is ‘value1’ and if not value1 but ‘value2’ then to display this block.

    Here is what I have so far

    $oriantation = get_field('oriantation');
    if ( $oriantation == 'left' ) { 
    
        Run Code 
    
    }
    elseif ( $oriantation == 'right' ) { 
    
        Run Code
    
    }
    else {
        return false;
    }

    This out puts the first block but if the checkbox is ‘right’ the elseif statement then it still returns the first block of code in the if statement.

    I’m just beginning to write my own statements and functions at the moment so any direction to where I’m going wrong would really help.

  • The topic ‘Advanced Custom Fields | if ifelse else statements’ is closed to new replies.
Skip to toolbar