[resolved] The_Post_Thumbnail in Get_Children Query (4 posts)

  1. brian317
    Posted 4 years ago #

    How can I use "the_post_thumbnail" within this "sub-pages" query? it all works great, just need that!

    $postChildren =& get_children( 'post_parent='.$post->ID.'' );
        foreach ($postChildren as $child) {
    print $child->post_title;
     $explodemore = explode('<!--more-->', $child->post_content);
    echo strip_tags($explodemore[0]) ."<p><a href='$link'>Learn more &raquo;</a></p></div>";

    there's currently a bit of code pulling huge unscrunched original images in my full version, it appears after the post_title above :

    $childChildren =& get_children( 'post_parent='.$child->ID.'' );
            foreach($childChildren as $newChild) {
    			print "<img src='".$newChild->guid."' height=100 width=100 />";}

    Works great, except for the fact that its gigantic images squeezed without aspect ratio maintennance into 100px square images.

    thank you

  2. Jacob Chappell
    Posted 4 years ago #

    the_post_thumbnail can only be used within a WP_Query loop. You'll need to create a WP_Query instance to replace get_posts.

  3. Michael
    Forum Moderator
    Posted 4 years ago #

    you could try to use:

    echo get_the_post_thumbnail($child->ID,'thumbnail');



  4. brian317
    Posted 4 years ago #

    alchymyth - you are my hero.

    problem solved.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.