• Hi,

    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!

Viewing 5 replies - 16 through 20 (of 20 total)
  • 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?

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

    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.

    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 https://core.trac.www.ads-software.com/ticket/18068 and
    https://permalink.gmane.org/gmane.comp.security.full-disclosure/80532

    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?

    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…

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘WP 3.2, wp_list_bookmarks, orderby=id: not working’ is closed to new replies.