• Hi,
    i am trying to get the feat image from a custom post type
    so normally it should work like this

      {% for person in people %}
                    <img src="{{ person.thumbnail.src }}"
                         alt="">
            {% endfor %}

    …but it doesn’t
    I have tried to do that in my context
    $context['thumbnail'] = new TimberImage(the_post_thumbnail());

    but then i don’t know how to use it..

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey Alexa-

    What page are you trying to do this on? Have you tried:

      {% for post in posts %}
                    <img src="{{ post.thumbnail.src }}"
                         alt="">
            {% endfor %}
    • This reply was modified 8 years, 2 months ago by patrickcee.
    Thread Starter alexadark

    (@alexadark)

    i am trying to do it for a custom post type named people,
    For normal posts it is working
    for CPT i can get the title and other things but not the thumbnail
    This is what i have to the context:

    $args                  = array(
    		'post_type'      => array( 'people' ),
    		'nopaging'       => true,
    		'posts_per_page' => '-1',
    	);
    	$people                = get_posts( $args );
    	$context['people']     = $people;

    I am quite new to timber

    • This reply was modified 8 years, 2 months ago by alexadark.
    • This reply was modified 8 years, 2 months ago by alexadark.
    • This reply was modified 8 years, 2 months ago by alexadark.
    Thread Starter alexadark

    (@alexadark)

    Solved it, i wrote get_posts instead of Timber::get_posts !!!
    to bad !

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Getting featured image from Custom Post Type’ is closed to new replies.