0

I've created a Rental custom post type to a rental site I'm developing for a client. I'd like to add an ajax availability calendar in the backend so the client can mark/unmark unavailable dates clicking on them, such as this:

http://i61.tinypic.com/j5l10p.png

I need to temporary store the marked dates somewhere so they don't get lost when the client moves through months back and forth. I'm wondering if using transients is the best option for this. Any ideas?

Thanks in advance

1

If you're using custom post types, i'd save those date entries as post_meta entries (http://codex.wordpress.org/Function_Reference/add_post_meta). So if your client clicks on a date, you start an ajax request to your plugin/theme file to add or remove a meta entry.

you can create one meta_entry named _availability for example and save all dates there (you can save multiple meta_entries to a post with the same name <= 1:n)

saving your dates as meta entries has the additional benefit that you can start a WP_Query that shows you all properties available today very easily.

br from salzburg,

  • Johannes
  • Yes, I plan to save the marked dates to a meta entry when the post is saved in the end. But, how can I save these dates if it's a new post? There's no post in the database to store meta data to, yet. That's why I thought I need some kind of temporary storage solution. – leemon Jul 13 '14 at 11:38
  • 1
    Wordpress creates a new - temporary - post if you create a new post. So, in a meta box you can access the global $post and get the ID. With help of codex.wordpress.org/AJAX_in_Plugins you should be able to save metadata that is still available after saving/publishing your new post. – jjarolim Jul 13 '14 at 14:19
  • I didn't know that WP created a temporary post when you create a new post. Thanks! – leemon Jul 13 '14 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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