Very basic php but can't get my head around it

Hello all,

I have no clue what I’m doing. I have installed Advanced Custom Fields plugin for Wordpress with which you can create custom fields in the back-end of the CMS. I have to add a line of php code to call the custom field and place it where I want it.

The standard code is working fine:

[php]<?php

if(get_field(‘juno’))
{
echo ‘

’ . get_field(‘juno’) . ‘

’;
}

?>[/php]

But I want to add some thing. So if the field ‘juno’ is filled. I want to display a header (within a div class) and after that call the field. I have now constructed the code below…as far as I can understand PHP it is now checking whether the field is filled. If so the rest of the code is run… but nothing is showing up…

My fabrication:
[php]<?php if (get_field('juno')): ?>

Buy


<?php echo the_field( 'juno' ); ?>

<?php endif;?>[/php]

Gratitude will be forever yours if you can help me out ;D

Why are you echoing out the_field???

[php] <?php echo the_field( 'juno' ); ?>[/php]

shouldn’t it be:
[php]echo ‘

’ . get_field(‘juno’) . ‘

’;[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service