get_field not working after loop
-
I just put a loop into my static home page custom template, working great. Now I’ve installed Advanced Custom Fields and have it set up. get_field() is not working for me in the custom page template – it works above the loop in the template source code but not below the loop. Here is my loop code:
<?php $latest = new WP_Query('showposts=3'); $count = 0; ?> <?php while( $latest->have_posts() ) : $latest->the_post(); ?> <? // prevent dotted border on top of first excerpt if ($count === 0) { echo '<p class="excerpt_title_p_first">'; $count = 1; } else { echo '<p class="excerpt_title_p">'; } ?> <?php the_title( sprintf( '<a href="%s" rel="bookmark" class="excerpt_title_a">', esc_url( get_permalink() ) ), '</a>' ); ?></p> <p class="excerpt_date"><?php fccp_posted_on(); ?></p> <p class="excerpt_content"><?php echo substr(get_the_excerpt(),0,140).'... <a href="'.esc_url( get_permalink() ).'" class="excerpt_read_more">more ?</a>'; ?></p> <?php endwhile; ?>
Why would get_field work above it but not below it? Is there an error in the loop code? Thanks in advance for your help – I know php but new to wordpress.
EDIT: I did try using get_field(‘{FIELD_NAME}’,{PAGE_ID}) also with no luck.
https://www.ads-software.com/plugins/advanced-custom-fields/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_field not working after loop’ is closed to new replies.