ThemeShaper Forums » Thematic

[closed]

List most recent post from 5 categories with thumbnail?

(2 posts)
  • Started 4 years ago by versatilist
  • Latest reply from Chris
  • This topic is not resolved
  1. versatilist
    Member

    I'm trying to pull the most recent post title and post image thumb from 5 categories (out of ~20) in a specific order. This list is in addition to another loop on the page (the main loop), or the single post/page.

    I need to pull the image thumbnail from that post, but NOT using any special fields (ala get-the-image plugin).

    Here is what I have so far (starting with 4):

    // Cat 1307
    echo '<li id="hcol4" class="header-post">';
    $posts_hcol4 = get_posts( "category=1307&numberposts=1" );
    if( $posts_hcol4 ) {
    foreach( $posts_hcol4 as $post_n4 ) {
    setup_postdata( $post_n4 );

    echo '<a href="';
    echo (get_permalink($post_n4->ID));
    echo '" title="Permanent Link to ';
    echo (get_the_title($post_n4->ID));
    echo '">' ;
    echo (get_the_title($post_n4->ID));
    echo '';
    }
    }
    echo '';

    // Cat 1303
    echo '<li id="hcol5" class="header-post">';
    $posts_hcol5 = get_posts( "category=1303&numberposts=1" );
    if( $posts_hcol5 ) {
    foreach( $posts_hcol5 as $post_n5 ) {
    setup_postdata( $post_n5 );
    /*print get_the_image(array('custom_key' => array('post_image_value'), 'default_size' => 'thumbnail', 'image_scan' => true, 'default_image' => get_bloginfo( 'template_url' ) . '/files/2009/11/sample.jpg', 'width' => '120', 'height' => '100', 'post_id' => $post_n5->ID));*/
    echo '<a href="';
    echo (get_permalink($post_n5->ID));
    echo '" title="Permanent Link to ';
    echo (get_the_title($post_n5->ID));
    echo '">' ;
    echo (get_the_title($post_n5->ID));
    echo '';
    }
    }
    echo '';

    Unfortunately the image is using the Global post variable. If I set the variable (post_id) only the first set works, all others use that same variable. It also seems like I should be able to do this with one query...

    I'm using the most recent version of thematic and a variation of thematicfeaturesite.

    Any ideas?

    Posted 4 years ago #
  2. Hi,

    if you follow the example on http://codex.wordpress.org/Template_Tags/get_posts, it should work. These examples are using the $post array also used by the Get-The-Image Plugin.

    Chris

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.