Support

Account

Home Forums Front-end Issues get_field not working with post excerpt

Solved

get_field not working with post excerpt

  • Hi there,

    I added

    <?php
    $args = array( ‘posts_per_page’ => 1 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    <h2>“><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <?php endforeach; ?>

    to my custom page template and the ACF get_field has stopped working. Does anyone knpw why?

  • Hi!

    Youve not pasted anything about the ACF fields but I’m guessing that these appear below that code and they’re attached to a different post..

    So what you need to do is put this after the endforeach:

    
    wp_reset_postdata();
    
  • Thanks Jonathan, funnily enough I found this out last minute last night and implemented it and it works! Great help though, I hope this helps others!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘get_field not working with post excerpt’ is closed to new replies.