WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] The_Post_Thumbnail in Get_Children Query (4 posts)

  1. brian317
    Member
    Posted 2 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;
    //the_post_thumbnail('thumbnail');
     $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
    Member
    Posted 2 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. alchymyth
    Forum Moderator
    Posted 2 years ago #

    you could try to use:

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

    http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail

    (untested)

  4. brian317
    Member
    Posted 2 years ago #

    alchymyth - you are my hero.

    problem solved.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.