webdev.ramyash@gmail.com

Web Development: Get post thumbnail by post id ("thumbnail,medium,large,full") in wordpress.


Get post thumbnail by post id ("thumbnail,medium,large,full").

Get post thumbnail by post id ("thumbnail,medium,large,full") in wordpress.

Get post thumbnail by post id ("thumbnail,medium,large,full").

<?php
// without parameter -> Post Thumbnail (as set by theme using set_post_thumbnail_size())
$postId=12;
get_the_post_thumbnail($postId );                 

get_the_post_thumbnail( $postId, 'thumbnail' );      // Thumbnail (Note: different to Post Thumbnail)
get_the_post_thumbnail( $postId, 'medium' );         // Medium resolution
get_the_post_thumbnail( $postId, 'large' );          // Large resolution
get_the_post_thumbnail( $postId, 'full' );           // Original resolution

get_the_post_thumbnail( $postId, array( 100, 100) ); // Other resolutions

You can also give Post Thumbnails their own class:
// Give the Post Thumbnail a class "alignleft".
echo get_the_post_thumbnail( $post_id, 'thumbnail', array( 'class' => 'alignleft' ) );

No comments:

Post a Comment