php - Is it possible to store date as meta_key in wordpress? -
i'm trying store dates , holidays in post_meta in wordpress database. made custom post type store data. in table wp_post, store _event_date = date , _event_holiday = holiday. problem can't query date has holiday want query. thinking store dates in "meta_key" fields, values stored in meta_keys needs have underscore. hesitate it.
my current codes follows.
this how store current data in wp_postmeta.
add_post_meta($post->id, "_event_name", $_post["_event_name"]); add_post_meta($post->id, "_event_date", $_post["_event_date"]);
this want instead.
add_post_meta($post->id, $_post[_event_date], $_post["_event_name"]);
would method have problems wordpress or something?
you may use without underscore this
add_post_meta($post->id, $_post['event_date'], $_post['event_name']);
but, if need store using preceding underscore
may use , there won't problem. btw, have this:
add_post_meta($post->id, $_post[_event_date], $_post["_event_name"]);
you should use quotes (single/double) $_post['_event_date']
if not typo.
Comments
Post a Comment