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' );
}
?>