• Resolved hazagawa365

    (@hazagawa365)


    Hi

    I have a column with images in it as a link.

    I want to sort the images by name, how do I do this?

    The images are stars. So 5 stars, 4 stars etc.

    I want to be able to sort the column by number of stars.

    But this isn’t working and is sorting in random orders. I’ve tried using numbers, letters but nothing works, it just sorts it in a random order.

    Please help on how I can sort an image in order.

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    For this, I recommend to use an approach like this: https://ww.wp.xz.cn/support/topic/sorting-function-with-images/

    You would essentially have to add another column to the table which has the star value as a number, and then instruct the sorting feature to use that column’s information for the sorting. (The column can then also be hidden from the visitor.)

    Regards,
    Tobias

    Thread Starter hazagawa365

    (@hazagawa365)

    Thanks tobias your a genius.

    Thread Starter hazagawa365

    (@hazagawa365)

    Still having some issues, unfortunately

    Thread Starter hazagawa365

    (@hazagawa365)

    Got this error message when I put the code in the custom commands “DataTables warning: table id=tablepress-2 – Incorrect column count”

    I used code – “columnDefs”: [ { “orderData”: [ 6 ], “targets”: [ 7 ] } ]

    I want the star rating images to sort.

    I’ve added a column for the sorting reference.

    You’ll also notice I have another column which works out the player’s date of birth.

    I’ve also hidden 3 columns (DOB, x2 sorting reference columns).

    I have 10 columns in total, including the 3 hidden columns.

    Please let me know where I’m going wrong.

    As I want to sort more than one column of images (potential rating and current rating), what code would I need to input for this?

    Thanks

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    make sure that the code in the “Custom Commands” only refers to the columns that are visible in the browser, not taking into account columns that are marked as hidden, when counting.

    Also, note that counting starts with 0 for the first column.

    To do this for multiple columns, duplicate the { "orderData": [ 6 ], "targets": [ 7 ] } part inside the columnDefs: [ ... ] command, combining those with a comma.

    Regards,
    Tobias

    Thread Starter hazagawa365

    (@hazagawa365)

    Great, thank you, but the only issue there is that the order data column would need to be hidden, so what column number would this if I don’t count it? If you know what I mean.

    Thanks

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    to hide that column, you will also have to hide it with JS code (or CSS code), and not on the “Edit” screen.

    So, a full “Custom Command” for this could be

    "columnDefs": [ { "orderData": [ 6 ], "targets": [ 7 ] }, { "visible": false, "targets": [ 6 ] } ]

    This example would mean that column 7 (denoted by the 6 in the code) has the numbers, and column 8 (denoted by the 7 in the code) has the images.

    Regards,
    Tobias

    Thread Starter hazagawa365

    (@hazagawa365)

    You are a genius, my friend. Thanks for your help. It’s all working now.

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! 🙂 Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Sorting images’ is closed to new replies.