• Resolved rwilki

    (@rwilki)


    Hey, I have a question for using shortcode to list display of fields.

    I’m using this shortcode with a filter to limit the list to a certain group. My display is showing the fields in ascending order according to the filter. I’d like it to show the fields in ascending order according to one of my fields instead, is this possible?

    [pdb_list fields="name,date_recorded,sex,age" filter="group_number=123"]

    My list seems to be sorting the list according to the date it was recorded, from oldest date to newest date. I’d like to know if it can show the fields listed above, but sort the list in ascending order the “name” field.

    Thanks,
    Bob

    https://wordpress.org/plugins/participants-database/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author xnau webdesign

    (@xnau)

    This is in the docs, check the “other notes” tab and look for instruction on using the shortcode to sort your list.

    Thread Starter rwilki

    (@rwilki)

    Hi thanks. This is the shortcode I’m now using. When I display my page and manually click on the sort button, it sorts appropriately. I was hoping the shortcode would do this for me but it’s not the end of the world.

    [pdb_list sort="true" orderby="name" order="asc" fields="name,date_recorded,sex,age" filter="group_number=123"]

    Secondly, do you know why #13 is sorting between #1 and #2? Is there a way around this?

    #1 Name
    #13 Name
    #2 Name

    Plugin Author xnau webdesign

    (@xnau)

    Shortcode sorting does work, but it looks like you’re expecting a numeric sort. If you have a field that combines numbers and text such as your example, it will never sort by the number. Sorting is done either alphabetically (the default) or numerically. If it’s to be sorted numerically, there can’t be any non-numeric characters in the field.

    If you want to sort by number, you need to store your numeric values in another field, and then set that field up as a numeric field…this is explained on the “other notes” page under sorting numerically.

    Thread Starter rwilki

    (@rwilki)

    OK, I understand and thank you for your explanation. I’ve modified my form and shortcode according to your notes.

    But, it’s still sorting my numerical field incorrectly.

    1
    13
    15
    2
    3
    4
    5

    [pdb_list orderby="number" order="asc" fields="number, etc...]

    I think the problem has to do with alphanumeric sorting as opposed to natural or integer sorting. Any ideas?

    Plugin Author xnau webdesign

    (@xnau)

    Yes, you need to alter the database so it will sort numerically. Read the “other notes” section on setting up a numeric sort.

    Thread Starter rwilki

    (@rwilki)

    Sorry for not reading all the way down on this page. Great and very thorough notes and support. Thanks Roland!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Sorting help on list fields display?’ is closed to new replies.