WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] List links by category name not ID (3 posts)

  1. josalmon
    Member
    Posted 8 years ago #

    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

  2. Kafkaesqui

    Posted 8 years ago #

    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");

  3. josalmon
    Member
    Posted 8 years ago #

    Brilliant! Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.