gpt4 book ai didi

wordpress - 添加图像尺寸时 get_the_post_thumbnail_url() 不起作用

转载 作者:行者123 更新时间:2023-12-03 07:24:45 26 4
gpt4 key购买 nike

当我尝试在 Wordpress 中使用 get_the_post_thumbnail_url() 时,遇到了奇怪的情况。

更准确地说,我有这个变量:

$postImage = get_the_post_thumbnail_url('article-thumbnail-image');

并且它返回一个空白值。如果我使用:

$postImage = get_the_post_thumbnail_url();

返回的值是正确的,但图像大小不同 (150x150)。现在奇怪的部分是如果我使用:

the_post_thumbnail_url('article-thumbnail-image');

它显示了正确的值,因为该图像大小已在 functions.php 中注册,但我需要使用 GET 函数。

我做错了什么吗?

最佳答案

get_the_post_thumbnail_url() 有两个参数。您需要使用 null 或 post_id/post 作为第一个参数,大小将是第二个参数。 https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/

关于wordpress - 添加图像尺寸时 get_the_post_thumbnail_url() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42188783/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com