• Resolved cerstrand_mace

    (@cerstrand_mace)


    I’m trying (and failing) to get the thumbnail from a post object chosen by an Advanced Custom Field Repeater. I get all the other post items just fine.

    This is what I got this far but clearly i’m not on the spot:

    <?php

    $post_object = get_sub_field(‘flow-post’);

    if( $post_object ):

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

    “> <div class=”flow-post”>

    <img src=”<?php the_post_thumbnail($post->ID, “medium”); ?>”>

    <h4><?php the_title(); ?></h4>

    <?php the_excerpt(); ?>

    </div>

    <?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    <?php else: ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter cerstrand_mace

    (@cerstrand_mace)

    Forgot to put it within code tags, sorry…

    <?php
    
    $post_object = get_sub_field('flow-post');
    
    if( $post_object ):
    
    // override $post
    $post = $post_object;
    setup_postdata( $post ); ?>
    
    "> <div class="flow-post">
    
    <img src="<?php the_post_thumbnail($post->ID, "medium"); ?>">
    
    <h4><?php the_title(); ?></h4>
    
    <?php the_excerpt(); ?>
    
    </div>
    
    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>
    
    <?php else: ?>
    Thread Starter cerstrand_mace

    (@cerstrand_mace)

    Got it! Removed the <img> tags around <?php the_post_thumbnail($post->ID, “medium”); ?>”>

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Post thumbnail within ACF repeater -> post object’ is closed to new replies.