• Resolved Bond323

    (@bond323)


    Hello,

    I have some posts where i’ve added an ACF datepicker field where i want to set the date of the event. If you are in the category “events”, i want display posts shortcode to order the posts based on the date of the ACF date field, and not the date of when the post is created. In the shortcode i’ve tried: orderby=”event_date”, but this is not working.

    How can i achieve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    [display_posts post_type=”events” orderby=”meta_value_num” meta_key=”be_event_date”]

    That assumes the meta field you’re storing the date in is called “be_event_date”. Also note that this simply sorts them by the date – it doesn’t limit the query to only upcoming events.

    For a more complicated query (like just upcoming events) I recommend you create a shortcut argument.

    It sounds like you’re using this plugin in place of the main query on the page. I recommend you instead modify the main query to show the events in the order you want. Here’s example codea tutorial that goes into more detail.

    Thread Starter Bond323

    (@bond323)

    Hello Bill,

    Right now i have the following shortcode:

    [display-posts include_excerpt=”true” image_size=”thumbnail” wrapper=”div” category=”evenementen” meta_key=”datum_evenement” orderby=”meta_value_num” order=”ASC”]

    Where “datum_evenement” is the name of the ACF datepicker field. When i view the page, it looks like display posts shortcode is sorting the posts, but it sorts on the day number only, and not the entire date that is filled in. For example there are 3 posts with the following dates:

    1. 25-12-2016
    2. 12-02-2017
    3. 19-11-2017

    It should sort like this: 1-2-3. But now it sorts like this: 2-3-1, it sorts the number of the day: 12 19 25. How can i fix this?

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

The topic ‘Sort by ACF Datepicker value’ is closed to new replies.