#3 wp_links: get_links(): allow to sort with more than one key

open
nobody
None
5
2003-10-04
2003-10-04
Michael Renzmann
No

Currently get_links() allows to specify only one key
for sorting. I was in need to have more than one key,
so I implemented a small change to the
get_links()-function to achieve this functionality. The
patch isn't expected to break compatibility, using the
function in it's old form (giving just one sorting key)
should work fine - but I didn't thoroughly checked
that. Let me know if there are problems with it.

Usage example:
The default index.php uses the following call to
display all links:
get_links(-1, '<li>', '</li>', '', 0, '_updated', 0, 0,
-1, -1);

With the patch applied, you could use this call instead:
get_links(-1, '<li>', '</li>', '', 0, '_rel, name', 0,
0, -1, -1);

This will sort the links for their relevance (highest
relevance first). Links with same relevance will be
alphabetically sorted.

Note that the "_" modifier (for changing the sorting
direction from ASCending to DESCending) still works,
and can be used individually for every key.

Discussion

  • Patch that allows definition of more than one sorting key for get_links()

     
    Attachments