WordPress.org

Ready to get started?Download WordPress

Forums

TablePress
[resolved] Sort kk star rating shortcode in table (4 posts)

  1. mchiampa
    Member
    Posted 1 year ago #

    Hi there,

    I am currently using the kk Star Ratings pluggin to rate my review posts. I also have a shortcode in one of your tables to show the results easily (e.g. [kkstarratings id="XXX"]). My page is here:

    Book Review Table

    This column does not sort properly. Can you think of a way to correct that? I know it probably has to do with the code but I can't figure it out.

    Thanks

    http://wordpress.org/extend/plugins/tablepress/

  2. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    thanks for your question.

    The reason for this is that the sorting algorithm can not know the numerical value of the rating, as all it sees is the HTML code for an image.
    Unfortunately, this is not easy to change, but you could try this: Please try adding this to the "Custom Commands" text field on the "Edit" screen of the table:

    "aoColumnDefs": [ { "sType": "html", "aTargets": [ 5, 6, 7 ] } ]

    if that does not work, you'll need to create additional columns (that are hidden to the user), and which do not contain the image HTML, but just the plain rating numbers.

    Regards,
    Tobias

  3. mchiampa
    Member
    Posted 1 year ago #

    Hi Tobias, thanks so much for responding. The code you posted above does not appear to work. As for your other proposal, I know how to create a hidden column, but how would I override the sorting of the column with the stars to sort based on the hidden column?

    Thanks

  4. TobiasBg
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    sorry to hear that this does not work :-(

    For this, you'd actually not hide the column on the "Edit" screen of TablePress (because that would also hide it from the sorting), but you would hide it with a different "Custom Command", additionally to telling the column with the star images to use the data in that new column for sorting.

    "aoColumnDefs": [ { "iDataSort": 3, "aTargets": [ 4 ] }, { "bVisible": false, "aTargets": [ 3 ] } ]

    That "Custom Command" would tell the fifth column (indicated by the 4), that the sorting should use the data from the fourth column (the first 3), and it would hide that fourth column (the second 3).
    That fourth column would then need to have the star ratings as a plain number, with nothing else.

    Regards,
    Tobias

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.