SHARE
TWEET

hierarchical link categories

a guest Jun 23rd, 2011 193 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $linkCats = get_terms('link_category');
  3. $i = 1;
  4. $catsToList;
  5.  
  6. foreach ($linkCats as $linkCat) {
  7.         if ($linkCat->parent == 5) {
  8.                 if ($i > 1) {
  9.                         $catsToList .= ", ";
  10.                 }
  11.                 $catsToList .= $linkCat->term_id;
  12.                 $i++;
  13.         }
  14. }
  15.  
  16. $topLevelCatList = array(
  17.         'category' => 5,
  18. );
  19. wp_list_bookmarks($topLevelCatList);
  20.  
  21. if ($catsToList) {
  22.         $subCats = array(
  23.                 'category' => $catsToList,
  24.         );
  25.         wp_list_bookmarks($subCats);
  26. }
  27. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top