A friend of mine wants the address in his footer to be editable. So I thought to add Custom Fields to a post and then, in the footer call that post (named "Info Post") and get the address from a custom field.
I can successfully get the ID of the post but when I try to get the post meta with
echo get_post_meta($post->ID, 'street_address', true);
nothing happens.
Could someone explain where I am going wrong? Or if anyone has an idea of how better to do this I'm all ears.
Thanks for any all help!
The code I was using to get $post->ID was requested so I have added it below I have attempted to reach the 'street_address' field in a variety of ways but none of them have worked. When I echo $post->ID I do get the correct ID though.
<?php
$queryObject = new WP_Query( array(
'title' => 'Business Info',
'posts_per_page' => 1,
));
?>
<?php if ( $queryObject->have_posts() ) : ?>
<?php while ( $queryObject->have_posts() ) : $queryObject->the_post(); ?>
<?php
// print_r($post);
$street_address = get_post_meta($post->ID, 'street_address', true);
?>
<div class="large-6 columns">
<h3>Our office location is at <?php echo $street_address;?>.</h3>
<!-- Image Here -->
<p>
<?php echo $post->ID; ?>
<?php
// print_r($post);
$street_address = the_field('street_address');
echo $street_address;
the_field('street_address');
?>
<br>
We'd love to see you there!
</p>
</div>
<?php endwhile;?>
<?php else: ?>
<?php endif; ?>
<?php wp_reset_query(); ?>