• Hi Everyone,

    Sorry for the long post. It’s a simple problem but hard for me to explain.

    I’m using a modified version of the WordPress template, on version 1.5. It’s at http://sterneworks.org/WordPress . Right now, I’m trying to get the links ordered properly in my sidebar. What I want is “basics (category ID #1), les links (#2), les blogs (#3)” in descending order below the search box and “categories.” But I get the opposite, which means that somewhere there is a bit of code telling it to place the lowest numbered category at the bottom and the highest numbered category at the top.

    In the WordPress interface, I can’t find any place to change the ID # for categories, and in the template, I can’t find the place where it says to put link categories from highest to lowest.

    Obviously, the kludge here is to delete all my links, and start over by ordering the category I want on top highest, but there must be a way to fix the code, no?

    Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Well, you could go into the database and manually swich IDs 1 and 3. Or, you can use WP functions to manually call in each category one-by-one. This is definitely an area of weakness in WP.

    I wrote this little snippet for you, havent tested it, but it should work:

    <?php $result = $wpdb->get_results("SELECT cat_id,cat_name FROM $wpdb->linkcategories");
    foreach ($result as $category) {
    $catid = $category->cat_id;
    $catname = $category->cat_name; ?>
    <li id="linkcat-<?php echo $catid ?>"><h2><?php echo $catname ?></h2>
    <ul>
    <?php get_links($catid, '<li>', '</li>', '', FALSE, 'id', FALSE); ?>
    </ul>
    <?php } ?>

    Thread Starter jsterne

    (@jsterne)

    Thanks for the replies.

    Mark — I tried messing with the categories in the database but it doesn’t seem to help. It’s possible that what’s happening is that because I want the links IN the category alphabetized, it’s also alphabetizing categories. Which would be unfortunate. What do you mean “manually calling categories one by one”? How would I do that?

    Silkjaer — thanks for the code, which I’m happy to try — but where do I paste it in?

    Best,
    –J

    just paste it in sidebar where where it currently grabs the links (<?php get_links_list() ?> or something like that.. ) – 🙂

    Uhm, sorry, if you want to alphabetize the links, you need to paste this instead;

    <?php $result = $wpdb->get_results("SELECT cat_id,cat_name FROM $wpdb->linkcategories");
    foreach ($result as $category) {
    $catid = $category->cat_id;
    $catname = $category->cat_name; ?>
    <li id="linkcat-<?php echo $catid ?>"><h2><?php echo $catname ?></h2>
    <ul>
    <?php get_links($catid, '<li>', '</li>', '', FALSE, 'name', FALSE); ?>
    </ul>
    <?php } ?>

    Thread Starter jsterne

    (@jsterne)

    Hi Silkjaer,

    Thanks. It appears to work! Eureka!

    Best,
    –J

    No problem

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Ordering LInks’ is closed to new replies.