• Hi,

    I have a custom column for a custom post type that I created by using the color picker and now contains the hex of one of 6 colors: red, dark-orange, light-orange, yellow, dark-green, light-green.

    I added this column to the list of sortable columns and set it to be sorted by using meta_value and not meta_value_num and now it works sort-of OK…

    The order they are sorted is different than what I want it to be. Currently, it’s light-green, dark-green, red, dark-orange, light-orange. I want it to be sorted in the order I listed them above (red, dark-orange, light-orange, yellow, dark-green, light-green).

    Any ideas on how to achieve this?

    Thanks,
    Yuval.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I assume you are creating a colorpicker plugin? You can used an array to sort the list.

    Thread Starter iyuvalk

    (@iyuvalk)

    Hi,

    Sorry… I think that probably I didn’t explain myself properly… Let’s try again:
    I have a custom field (meta data) that contains a color represented by an RGB hex value like #FF00FF. I want WordPress to sort the posts by this value but in a particular order like red, dark-orange, light-orange, yellow, dark-green, light-green regardless of the alphabetical order of the hex values.

    What would be the best way to achieve this?

    Tnx
    Yuval.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sorting a custom column that contains color (ColorPicker)’ is closed to new replies.