WP 3.2, wp_list_bookmarks, orderby=id: not working (21 posts)

  1. kellyb4
    Posted 4 years ago #


    I recently updated to WordPress 3.2. When I did, my list of bookmarks stopped working correctly. They always displayed ordered by id, as I had specified in my PHP code, but now they display by name.

    Here's my code:

    <?php wp_list_bookmarks('orderby=id&order=DESC&category=373&categorize=0&title_li=0&limit=10&after=<div id="whitenoise-linkdivider"></div><li>&show_description=1'); ?>

    Any idea what's going on?

    I have set orderby to rand. It works, and is an acceptable short-term substitute.

    Thanks for your time!

  2. Tara
    Volunteer Moderator
    Posted 4 years ago #

  3. becomeyoung
    Posted 4 years ago #

    I am having the exact same problem with my blog. Tried disabling all the plugins, and it didn't do anything. Seems like it might be a bug with the latest version of WP...

  4. s5nelson
    Posted 4 years ago #

    This seems to be a bug with the latest version of WP. I am having the same issue across multiple WP sites.

    I haven't come up with a workaround yet.

  5. esmi
    Forum Moderator
    Posted 4 years ago #

    Can you confirm this using Twenty Eleven and no active plugins?

  6. s5nelson
    Posted 4 years ago #

    Yes. I have installed Twenty Eleven and disabled all plugins and still have this issue. It seems that the "orderby => 'id'" class is no longer recognized.

  7. wmmead
    Posted 4 years ago #

    I am having the same problem.

    I installed a fresh copy of wordpress 3.2.1 and put in a very stripped down theme and tested the orderby=id and it worked fine.

    On my production site, I disabled all plugins with out getting any result. Then I did a manual install of wordpress and no result there either.

    My conclusion is that there must be something about my theme that is messing it up, but I can't imagine what. This is a very simple call to the database.

    If anyone finds a solution, please let me know.

  8. esmi
    Forum Moderator
    Posted 4 years ago #

    It seems to be working for me. If your links are in a number of different categories, have you checked out the category_orderby and category_order attributes. They will be altering the order of the final list of links.

  9. s5nelson
    Posted 4 years ago #

    I've used both category_orderby and category_order with no change.

    Every other type of orderby is working except the id.

  10. wmmead
    Posted 4 years ago #

    Thanks esmi, however, I am only using one category and have it listed in the parameters. This is the code I am using:

    <?php wp_list_bookmarks('title_li=&categorize=0&category=2&before=<p>&after=</p>&show_images=0&show_description=1&orderby=id&order=ASC&link_after=<br />'); ?>

  11. kellyb4
    Posted 4 years ago #

    It's encouraging, in a way, to see that others are having this problem. I don't feel so crazy.

    Just to update, I haven't been able to fix this problem since I first posted. Then again, I haven't done a clean install yet.

  12. raskull
    Posted 4 years ago #

    change this:

    to this:

    That should solve your problems. Sadly it doesn't solve mine; I had been ordering by 'notes' but that functionality seems to have disappeared. Here is a quick test I did on the supposed orderby values. Y=works

    Y 'id' (use 'link_id' with WP 3.2 and later)
    Y 'url'
    Y 'name' - Default
    N 'target'
    N 'description'
    ? 'owner' - User who added bookmark through bookmarks Manager.
    M 'rating' [sort of, all links need to be rated, or the rated links go to end of an id-sorted list
    ? 'updated' Note: the link_updated field does not track local modifications. It tracks when whatever the link points to is updated via remote requests to pingomatic.
    N 'rel' - bookmark relationship (XFN).
    N 'notes'
    N 'rss'
    Y 'length' - The length of the bookmark name, shortest to longest.
    Y 'rand' - Display bookmarks in random order.

  13. s5nelson
    Posted 4 years ago #

    This worked! Thank you SO much raskull!

  14. wmmead
    Posted 4 years ago #

    Worked for me too! Where the heck was this documented?

  15. raskull
    Posted 4 years ago #

    I had been using 'notes' to order the links by entering 01, 02, ... 10 in the Notes text boxes -- worked just fine. In fact I actually numbered them 05, 10, 15, 20, etc to allow for infill without renumbering. Now that that functionality is gone, I guess I will have to order by 'id' and remake the links in the order I want them. There has to be a better, plugin-less way!

  16. kellyb4
    Posted 4 years ago #

    Hey Raskull, thank you very much! orderby=link_id worked for me. I really appreciate it!

  17. apurdam
    Posted 4 years ago #

    Argh! When did they remove orderby=notes ?
    I'm still using WP 3.1.4 and I noticed that my custom lists are no longer in the order they used to be (defaulting to orderby=name by the looks).
    And (reading the above reports) now more have broken.
    Has anyone done a bug entry for this?

  18. apurdam
    Posted 4 years ago #

    btw: thanks for the research raskull.
    It saved me several hours of testing.
    But now how to do custom sorting of my links?

  19. apurdam
    Posted 4 years ago #

    A bit more research... This is for 3.1.4
    The bug appears to be in get_bookmarks in wp-includes/bookmark.php
    It seems that when code was added to the orderby processing to change id to link_id etc, they forgot about notes and its friends.
    As of 3.1.4, the following happens:

    1. length, rand and link_id get dealt with as special cases.
    2. Otherwise it's assumed to be a list (maybe a list of one), exploded and for each element:
      • 'name', 'url', 'visible', 'rating', 'owner', 'updated' are converted to link_name, link_url etc. Note that id is not in this list.
      • Other entries are ignored and not passed at all.

    To my mind, this would mean that the only arguments that would work would be name, url, visible, rating, owner, updated, link_id, length and rand, which agrees with raskull's findings.

    The workaround (which I can confirm only for 3.1.4 and for the argument notes, which was all I am interested in) is to

    1. edit wp-includes/bookmark.php
    2. find the line that says "if ( in_array( $ordparam, array( 'name', 'url', 'visible', 'rating', 'owner', 'updated') ) ) and add ,'notes' to the end of the array.
    3. Note that the line following the above one seems to have a foreign character in it. Not sure why, but I just left it there.

    Hopefully the bug will be fixed in a future version, but I'll need to work out how to report it accurately so that something will actually be done.

  20. apurdam
    Posted 4 years ago #

    Searching for more info on this bug, it was reported for 3.1.4 on 11th July 2011. It may be that notes were removed from orderby in 3.1.4 to prevent possible SQL Injection security issues if someone hacks your site with Editor privileges.
    See http://core.trac.wordpress.org/ticket/18068 and

    Please note that what I suggest in my previous post actually undoes this "security patch" (3.1.3 to 3.1.4), bringing the security back to 3.1.3's level. You should consider this before implementing my suggested "fix".

    Assuming that orderby=notes will remain disallowed, it leaves us back at the same problem, how to do arbitrary sorting of links?

  21. raskull
    Posted 4 years ago #

    Thanks for that valuable research, apurdam. I guess for now, the only way to have control over your link order is to create (recreate) them in the order in which you want them to appear (and use link_id) or name them alphabetically ( and use the default orderby ''name' )... Going off now to see if I trick the 'length' orderby with some spaces or something...

Topic Closed

This topic has been closed to new replies.

About this Topic