I am new to wordpress.

Specify the Id of the post page and

I want to display an eye-catching image.

I don't know how to write it.

<? php the_post_thumbnail ('thumbnail');?>

It seems that an eye-catching image is displayed by writing


I don't know how to specify and display the post ID.

  • Answer # 1

    the_post_thumbnail () is a function used in a WordPress loop, so the loop post ID is automatically used in the_post_thumbnail function.
    Therefore, any post ID cannot be specified for the_post_thumbnail function.

    If you want to get a thumbnail by specifying a post ID, use theget_the_post_thumbnail ()function.

    <? php echo get_the_post_thumbnail ($post_id, $size, $attr);?>

    For details, see
    See template tag/get the post thumbnail.