如何使用缩略图获取wordpress类别列表?

时间:2014-06-20 18:16:39

标签: php json wordpress api echo

我正在尝试使用缩略图图片获取缩略图列表。我尝试了下面的代码,但它只给出了类别列表。我知道有可能使用feed_image,但我无法弄清楚如何做到这一点。请帮助我,我只是wordpress的初学者

 $args = array(
 'show_option_all'    => '',
 'orderby'            => 'name',
  'order'              => 'ASC',
 'style'              => 'list',
  'show_count'         => 0,
  'hide_empty'         => 1,
  'use_desc_for_title' => 1,
  'child_of'           => 0,
  'feed'               => '',
  'feed_type'          => '',
  'feed_image'         => '',
  'exclude'            => '',
   'exclude_tree'       => '',
   'include'            => '',
   'hierarchical'       => 1,
   'title_li'           => __( 'Categories' ),
  'show_option_none'   => __( 'No categories' ),
   'number'             => null,
    'echo'               => 1,
    'depth'              => 0,
     'current_category'   => 0,
    'pad_counts'         => 0,
     'taxonomy'           => 'category',
     'walker'             => null
        ); 

         echo wp_list_categories( $args );

1 个答案:

答案 0 :(得分:1)

Wordpress类别没有内置的“cat image”。

您必须通过更改核心代码自行添加,或者将描述字段用作图像路径的伪字符串

<img src="<?php echo category_description( $category_id ); ?>" />

您可能误解了feed_image的含义

http://codex.wordpress.org/Template_Tags/wp_list_categories

feed_image---
(string) Set a URI for an image (usually an rss feed icon) to act as a link to each 
categories' rss-2 feed. This parameter overrides the feed parameter. There is no default
for this parameter.

另一种解决方案是使用插件

https://wordpress.org/plugins/categories-images/