WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Theme code orders links in order of creation (8 posts)

  1. venator48
    Member
    Posted 8 years ago #

    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?

  2. Mark McKibben
    Member
    Posted 8 years ago #

    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.

  3. venator48
    Member
    Posted 8 years ago #

    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.

  4. venator48
    Member
    Posted 8 years ago #

    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?

  5. Mark McKibben
    Member
    Posted 8 years ago #

    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.

  6. venator48
    Member
    Posted 8 years ago #

    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.

  7. Mark McKibben
    Member
    Posted 8 years ago #

    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.

  8. venator48
    Member
    Posted 8 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags