Hi all, the fields I’m putting in my footer.php are coming up blank on page load. I can’t see anything I’ve done wrong. In the process of debugging I’ve made the functions.php code as simple as possible:
<?php
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
?>
I’ve then set up three simple text fields:
And called them in the footer.php code:
<div class="section center">
<h1 class="fadein"><?php the_field('get_in_touch'); ?> <br/>
<div class="underline"></div>
</h1>
<h2 class="fadein">
<?php if( get_field('tell_me_about_your_project') ): ?>
<?php the_field('tell_me_about_your_project'); ?>
<?php endif; ?></h2>
<div class="fadein">
<a class="more" data-toggle="modal" data-target="#emailMe">
<span>
<?php the_field('talk_to_me'); ?>
</span>
</a>
</div>
</div>
Unfortunately the fields just don’t seem to do anything on the actual page. I’ve tried changing them from their default values, but that doesn’t change anything either unfortunately. Any pointers?
Functopus,
When retrieving values from an option page, you have to put ‘option’ as the second parameter in the get_field() and/or the_field() functions.
So for your first field, you would use:
the_field('get_in_touch', 'option');
You can learn more about this in the documentation:
https://www.advancedcustomfields.com/resources/options-page/
Look at the template usage section
Amazing, thanks. Should have caught that myself really. I’m still feeling dopey from the festival I was at over the weekend – really appreciate the help.