Support

Account

Home Forums General Issues Page Options conditional not working in the footer.

Solved

Page Options conditional not working in the footer.

  • Just getting started with ACF.

    Trying to get my basic conditional to work in the footer.php file.

    <?php $adkCopyright = the_field(‘adk_copyright’,’option’);
    if($adkCopyright != ”) {
    echo $adkCopyright;
    } else {
    echo bloginfo(‘name’);
    } ?>

    I have a text field setup in a footer options page. I would like what is entered to replace the default bloginfo-name in the footer. I seem to be getting both the adk_copyright and bloginfo appearing.

  • You’ll probably want to use get_field instead of the_field in your assignment. the_field will display the retrieved value automatically which is why you’re seeing duplicate output.

    
    <?php
    $adkCopyright = get_field( 'adk_copyright', 'option' );
    
    if ( !empty( $adkCopyright ) ) {
      echo $adkCopyright;
    } else {
      echo bloginfo( 'name' );
    } 
    ?>
    
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Page Options conditional not working in the footer.’ is closed to new replies.