This short CRED Code allows you to get the TODAY’s Date in seconds from Timestamp begin and update a Date Field (Types) with this value. Since Views can currently not handle post_date in Parametric Searches this can be useful to find posts by Publish Date (let’s say you updated the CF with TODAY date on post creation)
/** *Update news post date to a CF since Views cant handle Post Date in param search */ function update_post_date_save_data_action($post_id, $form_data){ // Change your CRED Form "ID" accordingly below if ($form_data['id']==ID){ // get current date, returns full Timestamp $post_date = date("U"); //update the CF with current post date update_post_meta( $post_id, 'wpcf-date_field_slug', $post_date ); } } add_action('cred_save_data', 'update_post_date_save_data_action',10,2);
Let us know if this snippet is not working for you:
This snippet doesn’t work