从帖子列表页面获取类别

时间:2013-08-10 15:19:11

标签: wordpress categories

我这样做是为了获取类别名称,我得到了数组

Array ( [0] => stdClass Object ( [term_id] => 4 [name] => cinematography [slug] => cinematography [term_group] => 0 [avhec_term_order] => 1 [term_taxonomy_id] => 4 [taxonomy] => category [description] => [parent] => 0 [count] => 11 [object_id] => 2526 [cat_ID] => 4 [category_count] => 11 [category_description] => [cat_name] => cinematography [category_nicename] => cinematography [category_parent] => 0 ) )

为此我写了

  $category = get_the_category();
  print_r($category);

现在我如何将“[name] => cinematography”存储在变量中。

1 个答案:

答案 0 :(得分:0)

我认为$category是你到那里的数组,然后是

$cinematography = $category[0]->cinematography;

https://drupal.org/node/1245956