spot_img
HomeWordPress教程wordpress建站公司 通过页面 ID 获取特色图片 URL

wordpress建站公司 通过页面 ID 获取特色图片 URL

JasperAI 10000字免费额度试用

我正在使用 WordPress 3.4.1。 我需要显示页面的特色图片。 如何通过特定页面 ID 获取特色图片 URL。 有什么帮助吗?

你尝试过什么吗? 分享您的尝试总是有帮助的。

$url = wp_get_attachment_url( get_post_thumbnail_id($post_id) );

或者,如果您想按图像大小获取图像。

$src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'thumbnail_size' );
$url = $src[0];

http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id

http://codex.wordpress.org/Function_Reference/wp_get_attachment_url

http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

从 WordPress 4.4.0 开始,我们可以使用 get_the_post_thumbnail_url():

高质量外链购买
$url = get_the_post_thumbnail_url( $post_id, 'thumbnail' );

5分钟生成10篇英文软文article forge软件试用
siteground guangda
WordPress花园官方账号
WordPress花园隶致力于为广大跨境电商和独立站爱好者提供优质的WordPress教程、Woocommerce教程、Facebook、Twitter、tiktok、Instagram教程和谷歌SEO教程等资料和对应的建站推广服务。关注‘哟派出海’公众号了解最新资讯。粉丝福利:Shopline免费独立站建设14天优惠 商务合作: [email protected]
RELATED ARTICLES
spot_img