admin管理员组文章数量:1025278
How do I get the URL of my featured image?
I am using buffy and I can Call The URL of The post and so on, but can't figure out how to Call The URL of The featured image.
How do I get the URL of my featured image?
I am using buffy and I can Call The URL of The post and so on, but can't figure out how to Call The URL of The featured image.
Share Improve this question edited Dec 31, 2014 at 14:42 Howdy_McGee♦ 20.9k24 gold badges91 silver badges177 bronze badges asked Dec 31, 2014 at 12:49 danielnndanielnn 11 bronze badge 1- you can learn about please visit wordpress.stackexchange/questions/76954/… – Dharmishtha Patel Commented Jun 26, 2018 at 5:19
3 Answers
Reset to default 1the_post_thumbnail()
is highest level function for it, which will output complete HTML. If you need some lower level parts, digging deeper are nested:
get_the_post_thumbnail()
wp_get_attachment_image()
wp_get_attachment_image_src()
Hey by using wp_get_attachment_image_src()
to get the featured image url like this
<?php
if ( has_post_thumbnail() ) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
}
?>
<img src="<?php echo $large_image_url[0]; ?>">
You can simply call the following function to get the url of the featured image depending on the size you want to print :
the_post_thumbnail_url( $size );
the size variable might be either a string : (thumbnail, medium, large, full) or a precisized width and height (24*24).
You can learn more about it by visiting this url : https://codex.wordpress/Function_Reference/the_post_thumbnail_url
How do I get the URL of my featured image?
I am using buffy and I can Call The URL of The post and so on, but can't figure out how to Call The URL of The featured image.
How do I get the URL of my featured image?
I am using buffy and I can Call The URL of The post and so on, but can't figure out how to Call The URL of The featured image.
Share Improve this question edited Dec 31, 2014 at 14:42 Howdy_McGee♦ 20.9k24 gold badges91 silver badges177 bronze badges asked Dec 31, 2014 at 12:49 danielnndanielnn 11 bronze badge 1- you can learn about please visit wordpress.stackexchange/questions/76954/… – Dharmishtha Patel Commented Jun 26, 2018 at 5:19
3 Answers
Reset to default 1the_post_thumbnail()
is highest level function for it, which will output complete HTML. If you need some lower level parts, digging deeper are nested:
get_the_post_thumbnail()
wp_get_attachment_image()
wp_get_attachment_image_src()
Hey by using wp_get_attachment_image_src()
to get the featured image url like this
<?php
if ( has_post_thumbnail() ) {
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
}
?>
<img src="<?php echo $large_image_url[0]; ?>">
You can simply call the following function to get the url of the featured image depending on the size you want to print :
the_post_thumbnail_url( $size );
the size variable might be either a string : (thumbnail, medium, large, full) or a precisized width and height (24*24).
You can learn more about it by visiting this url : https://codex.wordpress/Function_Reference/the_post_thumbnail_url
本文标签: phpCall featured image url
版权声明:本文标题:php - Call featured image url 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745609053a2158896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论