I have a number of custom fields that I want displayed on my wordpress page, so I used the below:
[php]
<?php if( get_field( "trainer_name", "address", "company", "address", "phone", "fax", "mobile", "email", "second_email", "website", "facebook", "twitter", "linkedin" ) !== '' ): ?> <p><?php echo the_field('trainer_name'); ?>
<p><?php echo the_field('address'); ?>
<?php echo the_field('company'); ?>
<?php echo the_field('phone'); ?>
<?php echo the_field('fax'); ?>
<?php echo the_field('mobile'); ?>
</p>
<a href="mailto:<?php the_field('email'); ?>"><?php the_field('email'); ?></a>
<a href="mailto:<?php the_field('second_email'); ?>"><?php the_field('second_email'); ?></a>
<a href="http://<?php echo the_field('website'); ?>"><?php the_field('website'); ?></a>
<a href="http://<?php echo the_field('facebook'); ?>">Facebook</a>
<a href="http://<?php echo the_field('twitter'); ?>">Twitter</a>
<a href="http://<?php echo the_field('linkedin'); ?>">Facebook</a>
<?php endif;?>[/php]
How can I add a line break ONLY if the custom field is present? I tried adding BR tags at the end of each statement, but it ends up echoing the
tag whether the field is present or not.
I’d appreciate the help. Total php noob here!