WordPress的不同的图像大小
在我的主题文件夹结构如下所示:WordPress的不同的图像大小
- 的wp-content /主题/主题/
- 谐音/
- 内容英雄.PHP
- 谐音/
我使用get_template_part('partials/content, 'hero')
来包含模板部分。
我在functions.php
中使用wp_calculate_image_sizes
筛选器将自定义大小属性添加到我的图像。我需要根据模板部分调用wp_get_attachment_image
函数来更改大小,但我不确定如何?
回答:
呼叫大小get_template_part之前到一个变量,如:所以现在内容hero.php内
$thesize = "here go the size you need"; set_query_var('variable_size', $thesize);
get_template_part('partials/content, 'hero');
,你将有可用的变量$ variable_size与你所需要的。
希望它适合你!
以上是 WordPress的不同的图像大小 的全部内容, 来源链接: utcz.com/qa/266742.html