Wordpress 从帖子列表页面获取类别的步骤
我这样做是为了得到类别名称,然后得到数组Wordpress 从帖子列表页面获取类别的步骤,wordpress,categories,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] =>
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”存储在一个变量中。我假设
$category
就是您在那里得到的数组,那么
$cinematography=$category[0]->cinematography代码>
$variable[“name”]=$cinematography代码>像这样?我想存储类别名称中的“电影摄影”。