2016-12-28 137 views
0

我想在div風格背景(xxxxx)中設置分類圖像url。我使用「分類圖像」插件,但wp_get_attachment_image不起作用。分類圖像div背景

<?php 
$terms = apply_filters('taxonomy-images-get-terms', '', array(
     'taxonomy'  => 'categoria_proyectos', 
    )); 

if (! empty($terms)) { 
    print ''; 
    foreach ((array) $terms as $term) { 
     print ' 
     <a href="' . esc_url(get_term_link($term, $term->taxonomy)) . '"> 
     <div class="style="background-image: url(xxxxxx); "> 
     </div> 
     </a>'; 
    } 
} 
?> 

回答

0

你可以試試這個代碼來獲取附加精選圖片的網址。

<?php echo wp_get_attachment_image(get_the_ID(), array('700', '600'), "", array("class" => "img-responsive")); ?>