如何显示没有父类别的WordPress类别名称?

时间:2019-01-21 09:04:50

标签: wordpress categories

我在wordpress网站上拥有此类别,仅显示子类别ID

library(highcharter)

    highchart() %>%
        hc_add_series_labels_values(labels = row.names(mtcars), values = mtcars$mpg, type = "pie")


I tried a lot, but was not able to recreate it with `hc_add_series`. 

如何仅显示子类别ID

Test1
  - Sub1OfTest1
  - Sub2OfTest1
Test2
  - Sub1OfTest2
  - Sub2OfTest2

1 个答案:

答案 0 :(得分:0)

<pre>

   $cat_all_id = "";
   $cat_all_args = array(
     'orderby' => 'name',
     'order' => 'DESC',
     'parent' => '',
     'hide_empty' => 0,
   );
   foreach(get_categories($cat_all_args) as $cat_all)
   {
      if($cat_all->parent != 0){
         if($cat_all->count > 0){
         $cat_all_id .= $cat_all->cat_name."|@|";
         }   
      }
   }
   $cat_all_id = explode("|@|",$cat_all_id);
   echo $cat_all_id[0];
   wp_reset_query();
</pre>