• Resolved edithmayerhofer

    (@edithmayerhofer)


    Hi,
    I have two custom fields for events (start-date and enddate). Now if I try to order by start-date

    [display-posts post_type="seminartermine" order="ASC" meta_key="seminarbeginn" orderby="meta_value" posts_per_page="4"]

    there is no output.

    If I use this shortcode

    [display-posts post_type="seminartermine" posts_per_page="4" order="ASC" orderby="seminarbeginn"]

    there is output but not ordered by date 🙁

    I am using the custom content type manager plugin for the custom post types.

    Any ideas please?

    https://ww.wp.xz.cn/plugins/display-posts-shortcode/

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

    (@billerickson)

    Are you positive that’s the correct meta key? If WordPress returns no results for the first shortcode query you provided, it means there’s no posts that have that meta key.

    You’ll also probably want to change orderby=”meta_value” to orderby=”meta_value_num”.

    meta_value would be for words (A-Z meta_key). meta_value_num is for numbers. I’m assuming your date is stored as a unix timestamp or YYYYMMDD so it’s actually sortable.

    Thread Starter edithmayerhofer

    (@edithmayerhofer)

    Meta_value_num did the trick. Thank you!

    Now I still have a problem when there are events with multiple startdates in an array. They are shown on the right order, but with the latest date of the array visible.

    I think, that might get difficult – but you already helped a lot.
    Thanks again.

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

The topic ‘ordering by date not working’ is closed to new replies.