0
votes

I have this category on my wordpress site only show sub category id

Test1
  - Sub1OfTest1
  - Sub2OfTest1
Test2
  - Sub1OfTest2
  - Sub2OfTest2

how to show only sub category id like this

  Sub1OfTest1
  Sub2OfTest1
  Sub1OfTest2
  Sub2OfTest2

1
Also look at wpbeginner.com/wp-tutorials/… You should find the answer there.Mulli

1 Answers

0
votes

<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>