开发者

WordPress custom content type date field

Hey, I'm trying to build the most intuitive possible Event post type. I'm wondering if there's a core method to both print out and capture the contents of a date field - specifically year/month/day, I don't need hours/minutes. I also need to be able to sort entries by date to print out later - for 开发者_开发技巧instance, I need all of the events from January. Something that can save me formatting the fields, and then parsing and saving them manually.

Any ideas are welcomed! Thanks in advance for your time.


There was no rock solid WP core solution to this, but the system I created is composed of:

SQL CONCAT to compare a date field to CURDATE, etc.

PHP strToTime to get the date back from the database

Generally speaking, if you save your date to the DB in UNIX time format it's easy to work with in SQL queries and in your PHP output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜