ACF plugin – showing data?
-
Hi,
So I started using Advanced Custom Fields but I am not sure how to use it, I have been through their documentation and I have managed to get SOME data out but not all….
<?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( ! $is_page_builder_used ) : ?> <h1 class="main_title"> </h1> <?php $posts = get_posts(array( 'numberposts' => -1, 'post_type' => 'pub', 'meta_key' => 'pub_name' )); if($posts) { echo '<ul>'; foreach($posts as $post) { echo '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a> - '. the_post('town').'</li>'; } echo '</ul>'; } ?>
My code here outputs the following:
another pub –
The Spotted Cow Inn –this is correct but ‘town’ is not being output?!
Please help
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘ACF plugin – showing data?’ is closed to new replies.