我主题中的文件夹结构如下所示:
我正在使用get_template_part('partials/content, 'hero')
来包含模板部分。
我在wp_calculate_image_sizes
中使用functions.php
过滤器为我的图像添加自定义尺寸属性。我需要根据调用wp_get_attachment_image
函数的模板部分来改变大小,但我不确定如何?
将get_template_part之前的大小调用为变量,如:
$thesize = "here go the size you need";
set_query_var( 'variable_size', $thesize );
get_template_part('partials/content, 'hero');
所以现在在content-hero.php里面你可以得到你需要的变量$ variable_size。
希望这对你有用!