Support

Account

Home Forums General Issues show post meta from previous post

Solving

show post meta from previous post

  • say I have an acf called “show_this_tomorrow” and every day (in a new post) I put some data into the field. And I want to show the value on the next days post. I was thinking I’d use this (code below) to grab it, but it doesn’t work in or outside the loop – <p><?php echo get_post_meta( $prev_post->ID, 'show_this_tomorrow', true); ?></p>

  • Might try:

    
    <p><?php echo get_field( 'show_this_tomrorow', $prev_post->ID ); ?></p>
    
  • unfortunately that didn’t seem to do it. neither inside or outside the loop. thanks for the suggestion ractoon.

  • Weird, if you echo $prev_post->ID is it filled in?

  • Answering a very old question just in case someone happens to be looking for an answer to this.

    There is no indication in the OP how the variable $previous_post is populated.

    For this see get_previous_post(). This call must be in “The Loop”

    
    $previous_post = get_previous_post();
    echo get_field('show_this_tomorrow', $previous_post->ID);
    
Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘show post meta from previous post’ is closed to new replies.