Get a field options by it’s name:

<?php if (get_field('field_name')) : ?>
    <?php the_field('field_name'); ?>
<?php endif; ?>

Change the value of a date field:

<?php if (get_field('field_name')) :
    $date = DateTime::createFromFormat('Ymd', get_field('field_name')); ?>
    <?php echo $date->format('d-m-Y'); ?>
<?php endif; ?>

Display image field:

<?php if (get_field('field_name')) :
    $image = get_field('field_name'); ?>
    <!-- Full size image -->
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>"/>
    <!-- Thumbnail image -->
    <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>"/>
<?php endif; ?>

 

Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.