WordPress.org

Support

Support » How-To and Troubleshooting » Problem with orderby in wp_list_bookmarks()

Problem with orderby in wp_list_bookmarks()

  • I’m probably making a basic error in syntax here, but I’ve tried various combinations of single and double quotes and can’t get this to work.

    According to the List Bookmarks reference, the ‘orderby’ parameter should accept multiple values as a comma-separated list.

    I’m trying to use this template tag to create a ‘blogroll’ page, as the sidebar version is getting too long.

    I’ve created my page template, and entered the function as follows:

    <?php wp_list_bookmarks('categorize=0&category_name=Links&title_li=0&orderby=rating,name'); ?>

    intending to get a list that’s sorted initially by rating, and then within groups of links with the same rating, by name.

    No dice. When I use it in this format, I just get a blank space under the page title (everything else displays fine). If I take out the ‘name’ portion, it displays, but appears to be displaying links with the same rating in order of the date they were added to the database.

    Have I misunderstood what I need to do here?

    Thanks,

    Rachael

Viewing 5 replies - 1 through 5 (of 5 total)
  • I can’t be sure, but this looks like it may be a bug. Code your orderby like this and see if it works: orderby=rating,link_name.

    Yes – that works fine. Is it a blooper in the codex documentation then?

    Nope, it is a bug. I created a ticket and it has been assigned to get a patch.

    I think if you use the actual database field names, it will work; the documentation says do this:

    orderby=rating,id

    It doesn’t work, but this does:

    orderby=rating,link_id

    The database field names are (in version 2.9.2) are:
    link_id
    link_url
    link_name
    link_image
    link_target
    link_description
    link_visible
    link_owner
    link_rating
    link_updated
    link_rel
    link_notes
    link_rss

    Yes, but notice that you use ‘rating’, not ‘link_rating’ as in the documentation. That is because the function prepends ‘link_’ to the front of the string instead of before each of the comma-separated values. This qualifies it as a bug.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem with orderby in wp_list_bookmarks()’ is closed to new replies.
Skip to toolbar