Support

Account

Home Forums Front-end Issues Post object in post

Unread

Post object in post

  • I have created a ACF for ‘Post Object’ and added it to the “news” page.

    It appears in the back-end I’ve filtered it by ‘Events’ and selected a post.

    However when try to output it in the front-end, nothing appears.

    `<?php

    $post_object = get_sub_field(‘selected_event’);

    if( $post_object ):

    // override $post
    $post = $post_object;
    setup_postdata( $post );

    ?>
    <div>
    <h3><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></h3>
    </div>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>`

    Any ideas why this won’t show??? When I move it to a field to page and not post it works?

Viewing 1 post (of 1 total)

The topic ‘Post object in post’ is closed to new replies.