• hamoon

    (@graphirancom)


    This code shows Post Images in the original size, but I want to show thumbnail in 160×213 pixel that I have in images folder. How can i do this?

             if( $cat_posts->have_posts() ) {
                                             while( $cat_posts->have_posts() ) :
                                                 $cat_posts->the_post();
                                                 $image  = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_id() ), 'images_posts' );
                                                 ?>
                                                 <li><a href="<?php the_permalink() ?>" ><img src="<?= $image[0] ?>" alt="<?php the_title(); ?>" width="125" height="125"/></a></li>
    
    

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • There are a lot of functions that deal with the post thumbnail.

    Moderator bcworkz

    (@bcworkz)

    In particular look for functions in Joy’s search results that accept a $size argument like get_the_post_thumbnail() which accepts a registered size argument or an array of arbitrary pixel dimensions. This one returns a complete img tag ready to echo out from a template.

    Hey @graphirancom,

    in your example the ‘images_posts’ string represents the size of the image.
    You can change this string to any registered thumbnail size name. or you can set it to ‘thumbnail’ to use the default thumbnail size.

    $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_id() ), 'thumbnail' );

    Regards,

    Stephan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do you get the post thumbnail ?’ is closed to new replies.