www.muttznutz.net

Underwater photography by Andy Kirkland

Link organisation with the Category Overload plugin

I’m also looking after my Club’s site, and have loaded Alex King’s CategoryOverload plugin.
This is cool, as it lets you build a hierarchy of link categories.

I’ve written a custom SQL routine - which I’ve included in one of our pages - to use this for output, by cycling through the different sub-categories of a parent (other links aren’t output).
This works with Wordpress 2.1.3.
Feel free to adapt it.

Here’s the skeleton code, for a “parent” category with an ID of 12.
Note that Php commands have an extra space inserted after the “< " to prevent accidental execution.

This first bit builds a array of sub-categories :-

<?php
$querystr =
SELECT cat_id, cat_name
FROM `wp_categories`
WHERE category_parent =12
order by cat_id
;
$linkcats = $wpdb->get_results($querystr, OBJECT); ?>

… Then this part loops through each subcategory and outputs it.
(you may want to put some formatting in …)

<?php if ($linkcats): ?>
<?php foreach ($linkcats as $linkcat): ?>
<?php echo $linkcat->cat_name ; ?>
<?php get_links( $linkcat->cat_id, , , , TRUE, ‘category’, TRUE, FALSE, -1, FALSE, TRUE); ?>
<?php endforeach; ?>
<?php endif; ?>

4 Comments ....

  1. I had a few problems getting the code to appear properly. My apologies to anyone affected.
    So I’ve installed the codesnippet plugin - which “colourises” the code as well. Thanks to those involved.
    I’ve also - hopefully - got the Comments function working as I’d like (if you can see this, then I have).
    This is mostly so I can give updates on topics.
    I’m afraid I’m not still opening them up in general, however, as I don’t have time to moderate all the spam entries.

    Posted by muttznutz on 20 May, 2007

  2. I’ve also used the Get Comments Count plugin from Mark Jaquith’s Tempus Fugit site.
    It should make posts summaries cleaner, by only highlighting posts where there is a comment.
    Here’s how I use it in my Category pages :

    <?php if (get_comments_count() > 0) : ?>
        This post has <?php comments_number(); ?>
    <?php endif; ?>

    Posted by muttznutz on 21 May, 2007

  3. The above code segments still seem to work with WP 2.2

    Posted by muttznutz on 25 May, 2007

  4. I’m just trying to upgrade to Wordpress 2.3.1
    Not everything�s working too well, but I’m trying to get through the new database structure.

    Key point - I’ve disabled CategoryOverload.
    I’ve hopefully made the code above a bit more compliant (using the $wpdb-> prefix).
    Some of the underlying tables have changed, so here’s a replacement for the SQL in the 13th May post (which seems to work for me).

    SELECT term_id, name
    FROM $wpdb->terms
    WHERE term_id IN
    (
       SELECT term_id
       FROM $wpdb->term_taxonomy
       WHERE parent=6
    )
    ORDER BY term_id

    As the ‘get_links’ tag - used above - is deprecated in WordPress 2.3, I suppose it’s probably best if you switch to the wp_list_bookmarks tag instead.

    Posted by muttznutz on 12 November, 2007

The URI to TrackBack this entry is: http://muttznutz.net/muttzblog/site-news/link-organisation-with-the-categoryoverload-plugin/2007/05/13/trackback

RSS feed for comments on this post.


Valid XHTML 1.0 Strict