Home › Forums › General Issues › ACF in attachment-single.php › Reply To: ACF in attachment-single.php
OK, it’s an error in the php logic. In your code you are saying IF chapo, display ‘chapo’ and also the_content(). You need to use ELSE to display one or another, such as:
<?php $field = get_field('chapo');?>
<?php if( !empty($field) ) { ?>
<?php echo $field; ?>
<?php } else { ?>
<?php the_content(); ?>
<?php } ?>
I am also adding a condition that says: if ‘chapo’ is not empty. Which is helpful most of the time.
Cheers!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.