php - Wordpress - Format a post meta (date) -
i want display date of event on revolution slider. managed display date using meta slug, don't format.
i have no idea start ! thought of, maybe creating post meta desired date format, update when first date meta updated, seems bit overkill ?
i have code add meta , update desired format : but there better way ?
function kia_convert_content(){ $events = get_posts(array('numberposts'=>-1,'post_type'=>'pec_events')); foreach( $events $post ) : setup_postdata($post); // old meta $mauvais_format = get_post_meta($post->id,'pec_date', true); // format date date_format($mauvais_format, 'j f y'); //add or update new meta if(metadata_exists('post', $post_id, 'l2v_pec_date')){ update_post_meta($post->id,'new_pec_date',$bon_format); }else{ add_post_meta($post->id, 'new_pec_date', $bon_format, true) } endforeach; }
wiki
Comments
Post a Comment