Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have three different custom fields, for day (01-07) hour (01-12) and minute (00-59) and I really need to combine them into one custom value so I can actually order them using wp_query.

I cant actually just use custom field for the whole thing; it would be easier I know, but it needs to be easy on the user to input day/time. So that option is out of the question.

Is it possible to join those three numerical values for use in wp_query?

Thanks in advance for any help.

David

share|improve this question
    
What the user fills out need not look like what you put into the database. Give the user whatever form you think is best but save to the database in a format usable to PHP, MySQL, and WordPress. –  s_ha_dum Jan 28 '13 at 19:44
add comment

1 Answer

If you want to make it as easy as possible on the user, then I think the best option would be to add a custom meta box with three fields for inputting the day/hour/minute values. Using something like a jQuery UI slider style timepicker would further simplify input. Then when the post is saved, use the save_post action to store those three values in a single field.

The second option is similar to the first, but you'd continue using the custom fields as you are now, except a fourth field would be added by you on the save_post action to combine them into a single field you use in your query.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.