Hierarchical Link Categories for WordPress

Download the plugin on WordPress.org

If you’ve ever tried to use WordPress’ built-in bookmarks / links manager, you know that its limits can be frustrating. One of the biggest issues I’ve encountered is that the link categories are not hierarchical.

Let’s say you have a tech blog and you link to a lot of pages about TV’s. You may want to categorize the links under TV > Plasma or TV > LCD. With the existing system, you cannot.

Enter the Hierarchical Link Categories plugin

Finally, with the new plugin by yours truly, you can create link categories that have parent categories. Blogroll categories can be nested, and the world breathes a sigh of relief.

What the plugin doesn’t do…yet:

  • When you’re in the “Add Link” page, you cannot add a child category
  • You tell me! Leave suggestions below.
This entry was posted in Plugins, Uncategorized, WordPress and tagged , , , , . Bookmark the permalink.
  • briana

    Hi for some reason the “parent” field does not show up for me. HELP! :)

    • http://www.seodenver.com Zack Katz

      What version of WP are you using?

  • stempere

    Hello,
    in doesn’t appear to work properly in WP 3.0.4:
    http://img218.imageshack.us/img218/1979/sanstitre1hhh.jpg
    http://img838.imageshack.us/img838/172/sanstitre2ks.jpg
    http://img218.imageshack.us/img218/2064/sanstitre3eg.jpg

    “Biographies” was created while creating the link and should be a child of “Artistes”.

  • Jim

    Not working in 3.0.5. No parent field showing up at all.

  • Shany

    Will there be an update soon, so it will probably work?

  • medb

    I have WP 3.1 and installed this plugin this evening. I’ve gone to Link Categories and successfully created parent categories with my sub-categories, but they are not displaying as such on my website. I still have each sub-category listed in my Sidebar #2 under “Links”. I have the latest version of the Suffusion theme, and have customized it quite a bit, so I’ve checked pretty thoroughly where else I might be missing a setting to fix this problem and can’t find anything.

  • Tcarey

    Now that I have my links in categories and subcategories, is there a way to display this to my users on my site.

  • http://handhugs.com Jessie

    I am confused. This helps on the back end of things, but it does nothing on the front end – is there some kind of code to list the links in a way that displays this hierarchy? Like the Links widget? I think this plugin should come with a widget that helps you display the intended results, otherwise it’s pretty silly.

    • http://www.pixelapes.com Alex Leonard

      I think I’ve worked out how to get the links of a children cat to display. The issue is that the parent-child relationship isn’t looked at by wp_list_bookmarks. Until the plugin has some functions of its own which you would use in the place of wp_list_bookmarks you’ll need to do something similar to:

      http://pastebin.com/Z2Exng3q

      I haven’t had time to turn this into a function, but will do soon. Basically you have to get all link cats, check if the link cat is related to your desired parent cat, and if it is, include it in a comma separated list which you then feed into the standard wp_list_bookmarks function.

      • http://www.pixelapes.com Alex Leonard

        I got round to writing a function today:

            /**
             * Prints bookmarks that are in link cat or child of link cat
             *
             * @param    string        $parent     ID of parent link cat
             * @return     echo                    Prints output via wp_list_bookmarks function
             */
            function pa_list_hierarchical_bookmarks($parent) {
                        $catsToList .= “, ” . $linkCat->term_id;
                   
               
                $subCats = array(
                    ‘category’ => $catsToList,
                );
                wp_list_bookmarks($subCats);
            }

        • Augie Weiss

          Where do I insert this code?

        • http://alex.leonard.ie Alex Leonard

          Wow, I can’t even remember where I was using this.. Hmm.

          Still, even though I can’t remember.. take the code above and insert it into your functions.php file.

          Then within your template file run the function 

          pa_list_hierarchical_bookmarks(5);

          Assuming the parent link category id is 5 in the example above – but replace with whichever link category  id you need to display.

        • Augie Weiss

          Thanks for the reply. 
          I would like to output a complete list of links with all children 3 deep. Is that possible?

        • http://alex.leonard.ie/ Alex Leonard

          I’m sure it is possible, but I’d need some spare time to delve into the code and see what I was doing with it. Sadly I’m a little too busy at the moment. 

          If I get a chance over the weekend I’ll look into it.

        • Augie Weiss

          Thanks a million.

        • Augie Weiss

          Where do I find the category ID?
          Thanks

        • http://alex.leonard.ie/ Alex Leonard

          To get the link category id, you need to go into your link categories edit screen in the back end.  Click the Edit (not quick edit) option for the link category you want to get the id of. On the edit screen check the URL – where it says &tag_ID=x, x is the ID of your link category.

        • Augie Weiss

          I see it now. Thanks

  • csolle

    So I take it this plugin doesn’t work…

  • http://thebestlifequotes.com/114/the-best-life-quotes-2/ The Best Life Quotes

    wow

  • Ben

    Hey, not sure if you’re still maintaining this project, but here’s a function that I cooked up that you can feel free to incorporate.  It returns the categories as a nested array (not as printable markup)

    function get_link_category_tree($trunk=0)
        $subcats = get_link_category_tree($category->term_id) ;
        $category->subcats = $subcats ;
        $ret[$category->term_id] = $category ;
      endif ;
     
      return empty($ret) ? false : $ret ;