[Support request] Sort by custom meta field?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Sort by custom meta field?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #4846
    Adrian
    Participant

    I run a movie database that shows new releases on the homepage.

    Currently, I can only order posts (movies) by date, meaning the date I created the page.

    Is there any way I can instead order by a custom meta field? I have one called release_date that would be more useful.

    #4852
    Tom
    Keymaster

    Hi there,

    So the release_date fields would all have dates, which you would sort by (newest to oldest)?

    Just looked into this. It looks like we can sort them by a custom field as long as it’s a number. I’m not sure a date would work unfortunately.

    #4875
    Adrian
    Participant

    Yeah it would have to be the release_date field, which is formatted like: 2017-01-27

    So no dice?

    #4881
    Tom
    Keymaster

    It may be possible, but we’d need to convert the date to a number, and then display the list using PHP. Is that do-able on your end, or are you using shortcodes within the content?

    #4889
    Adrian
    Participant

    I’m using shortcodes. But it’s ok, there’s another way I can accomplish this that won’t require customization. I was just wondering of something might have already been built in for this. But thanks for looking into it!

    #4899
    Tom
    Keymaster

    No problem. Let me know if you decide to go the PHP route and we can look into it some more 🙂

    #5923
    shpr
    Participant

    Hi @Tom @Adrian

    I am trying to do the same thing for events: I have a custom field (date) and would like to sort by it. I also currently use the short code.

    Just checking how you would recommend accomplishing this @Tom (or how you did it @Adrian).

    Thanks

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.