2017-12-27 415 views
0

在我的主題文件夾結構如下所示:WordPress的不同的圖像大小

  • 的wp-content /主題/主題/
    • 諧音/
      • 內容英雄.PHP

我使用get_template_part('partials/content, 'hero')來包含模板部分。

我在functions.php中使用wp_calculate_image_sizes篩選器將自定義大小屬性添加到我的圖像。我需要根據模板部分調用wp_get_attachment_image函數來更改大小,但我不確定如何?

回答

0

呼叫大小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與你所需要的。

希望它適合你!

相關問題