Support » Themes and Templates » List links by category name not ID

  • Resolved josalmon

    (@josalmon)


    Hi everyone,

    I’ve justed started using the Tiga theme but I can’t figure out how to list my links by category name and not ID.

    The current code looks like this:

    <?php
    $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
    foreach ($link_cats as $link_cat) {
    if (get_links($link_cat->cat_id, '', '', '', FALSE, '', FALSE, FALSE, -1, FALSE, FALSE)) {
    ?>
    <div class="left-widget-title"
    id="linkcat-<?php echo $link_cat->cat_id; ?>">
    <?php echo $link_cat->cat_name; ?>
    </div>
    <div class="left-widget">
    <ul>
    <?php wp_get_links($link_cat->cat_id); ?>
    </ul>
    </div>
    <?php
    }
    }
    ?>

    Any ideas about what I should change it to? I did look at the codex but I didn’t understand it!!

    http://www.josalmon.co.uk

    Thanks, Jo

Viewing 2 replies - 1 through 2 (of 2 total)
  • Codex would have little to say about the code above since it’s custom to the theme. Try changing the $link_cats line at top to:

    $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories ORDER BY cat_name");

    Thread Starter josalmon

    (@josalmon)

    Brilliant! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List links by category name not ID’ is closed to new replies.