How to add a "custom" date field to a custom post type?
Hey guys, I have a custom post type, portfolio, and I want to store the date of the projects. I can achieve it the "regular" way with a meta box but I would like a "datepicker" or something like it.
Any ide开发者_JAVA技巧a how?
Use the awesome time saving plugin Custom Field Template which uses a nice date picker (http://wordpress.org/extend/plugins/custom-field-template/)
it may be a bit odd to use at first, but once you get the hang of it it's very powerful. You can specify a custom meta box for just your custom post type.
Here is what you'd enter to get the date working.
[portfolio_date]
label = Portfolio Date
type = text
date = true
dateFormat = yyyy-mm-dd
the custom field is called portfolio_date
I change the date format so that it's easier to sort in queries. The default one is not good for sorting.
and if you need the date to start earlier than today's date add this
startDate = "2009-01-01"
精彩评论