WordPress.org

Ready to get started?Download WordPress

Forums

Participants Database
[resolved] Sorting help on list fields display? (7 posts)

  1. rwilki
    Member
    Posted 10 months ago #

    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/

  2. xnau
    Member
    Plugin Author

    Posted 10 months ago #

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

  3. rwilki
    Member
    Posted 10 months ago #

    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

  4. xnau
    Member
    Plugin Author

    Posted 10 months ago #

    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.

  5. rwilki
    Member
    Posted 10 months ago #

    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?

  6. xnau
    Member
    Plugin Author

    Posted 10 months ago #

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

  7. rwilki
    Member
    Posted 10 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.