admin管理员组文章数量:1391969
I currently have a custom theme with some images in a separate image folder and I pull them into the frontend with the echo get_theme_file_uri('/img/image-name.jpg')
which works as expected.
I would like to be able to add images from the media library, I know I can do this with the_post_thumbnail()
, but this obviously pulls in the post thumbnail relating to a post, whereas I've designed a page that uses 4 different images.
Is there a template tag that pulls in an image out of the media library onto a page where I can use the image's ID, so you get the benefits the_post_thumbnail()
brings in terms of sizing images etc ?
Any help would be amazing.
I currently have a custom theme with some images in a separate image folder and I pull them into the frontend with the echo get_theme_file_uri('/img/image-name.jpg')
which works as expected.
I would like to be able to add images from the media library, I know I can do this with the_post_thumbnail()
, but this obviously pulls in the post thumbnail relating to a post, whereas I've designed a page that uses 4 different images.
Is there a template tag that pulls in an image out of the media library onto a page where I can use the image's ID, so you get the benefits the_post_thumbnail()
brings in terms of sizing images etc ?
Any help would be amazing.
Share Improve this question edited Feb 26, 2020 at 14:41 pjk_ok asked Feb 25, 2020 at 23:58 pjk_okpjk_ok 9082 gold badges15 silver badges36 bronze badges1 Answer
Reset to default 2The equivalent function for arbitrary images that aren't the post thumbnail is wp_get_attachment_image()
. It works similarly, but you need to pass the attachment ID, and there's an $icon
argument that doesn't really do much:
echo wp_get_attachment_image( $attachment_id, 'large', false, [] );
版权声明:本文标题:page template - Is There A Way Of Using the_post_thumbnail() to Pull In A Specific Image From The Media Library 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744714182a2621301.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论