Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I created a WordPress custom post type to be able to create events, select the event's date, and display the date on the frontend.

I added a new meta_key in the postmeta of WP's database to store the event's date in a UNIX timestamp.

I've had no trouble creating a new WP query to output my events on my site but I am trying to figure out how to organize the events by their UNIX timestamp in the database, not by the date that WordPress created the events.

I can't seem to wrap my head around the thing.. any advice?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
954 views
Welcome To Ask or Share your Answers For Others

1 Answer

I believe your query can have

'orderby' => 'meta_value_num',
'meta_key' => 'event_timestamp' //or whatever your meta_key is

you can read about it here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...