WordPress.org

Support

Support » Themes and Templates » [Resolved] Theme code orders links in order of creation

[Resolved] Theme code orders links in order of creation

  • venator48

    @venator48

    which is their ID number. I want to control the order, at least to make it aphabetical.

    Here is the sidebar.php relevant code:
    —————–
    Links
    </div>

    <?php
    $link_cats = $wpdb->get_results(“SELECT cat_id, cat_name FROM $wpdb->linkcategories”);
    foreach ($link_cats as $link_cat) {
    ?>
    <div class=”sidetext” id=”linkcat-<?php echo $link_cat->cat_id; ?>”><div class=”sidetext” align=”left”><?php echo $link_cat->cat_name; ?>
    </div>
    <?php wp_get_links($link_cat->cat_id); ?>
    </div>
    <?php } ?>

    <?php } ?>

    ——————-

    What should I be changing?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Use get_links_list instead of wp_get_links. If you use: <?php get_links_list('name'); ?> It should give you a list of links in alphabetical order.

    venator48

    @venator48

    Thank you. This is clearly on the right track, but there are complications.

    Results of substituting:

    <?php get_links_list(‘name’); ?>

    for

    <?php wp_get_links($link_cat->cat_id); ?>

    did alphabetize links categories list. However, it also:

    1) changed link category headers to match font and font size and color of post headers;

    2) (At least some) former link category headers survived change, and appeared as well;

    3) Link categories and links repeated to bottom of sidebar.

    venator48

    @venator48

    An simpler way to re-order the link categories should be to edit the link category ID numbers. Do you happen to know which Directory:file the actual list can be found in?

    The links aren’t stored in a specific file that you can edit like that. They’re stored in your MySQL database. You’ll need something like phpMyAdmin on your server in order to go into the database and edit the IDs.

    Or you could try using one of the other tags for links: get_links, wp_get_linksbyname or get_linksbyname.

    venator48

    @venator48

    Isn’t it necessary to suppose that the absence of “($link_cat->cat_id);” in the revised version had something to do with the fact that the modified syntax also:

    1) changed link category headers to match font and font size and color of post headers;

    2) (At least some) former link category headers survived change, and appeared as well;

    3) Link categories and links repeated to bottom of sidebar.

    It’s hard to tell exactly what’s going on at this point with your list’o’links without a URL to the site your working on. But you can probably fix the remaining problems by adjusting your CSS.

    venator48

    @venator48

    A) I do have phpMyAdmin on my server. I went in and renumbered their IDs, but it was very time-consuming, and I still had a glitch in the order.

    B) So I just blew away my old link categories, and added the same ones back in the order I wanted. Strangely, some categories (same as in phpMyAdmi editing, cambe back –at least the first time– in the wrong order. God knows what causes that. I’m reading PHP syntax, so I can follow WordPress and Theme coding.

    But if you have to learn PHP and CSS in order to repair one of these WordPress Blogs, I do wonder why I didn’t just roll my own in HTML to begin with.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Theme code orders links in order of creation’ is closed to new replies.
Skip to toolbar