2016-09-25 75 views
0

我想显示具有特定分类的图像的所有术语。我使用get_term()函数获得所有术语详细信息。如何在wordpress中获得术语/分类图像?

​​

但它显示所有图像相同的路径。 http://localhost/mototrader/wp-includes/images/media/default.png

我怎么能得到与该分类相关的图像的实际路径。

在此先感谢。

+1

你怎么连图像设置为分类试试?我不认为这是标准的WP。所以,如果你知道你是如何设置它的,你将能够找到,如何得到它。 – Omnisite

回答

0

您可以通过这种方式也

<?php 
$cat_id = get_query_var('cat'); 
$catlist = get_categories('hide_empty=0&child_of=' . $cat_id); 
echo "<ul>"; 

foreach($catlist as $categories_item) 
{ 
echo '<h1><a href="' . get_category_link($categories_item->term_id) . '" title="' . sprintf(__("View all products in %s"), $categories_item->name) . '" ' . '>' . $categories_item->name.'</a> </h1> '; 

echo '<div class="categoryoverview clearfix">'; 
    $terms = apply_filters('taxonomy-images-get-terms', ''); 
    if (! empty($terms)) { 

     foreach((array) $terms as $term) { 
     if($term->term_id == $categories_item->term_id) { 
      print '<a href="' . esc_url(get_term_link($term, $term->taxonomy)) . '">' . wp_get_attachment_image($term->image_id, 'thumbnail'); 
      echo '</a>'; 

     } 
    } 
    echo '<p>'. $categories_item->description; echo '</p>'; 
} 
echo '</div>'; 
} 
echo "</ul>"; 
相关问题