Redirect to URL if x number of days passed

To redirect after 3 days gone after publication, hook into template_redirect, check if is a singular cpt view, check the date and compare to current time and redirect if needed. In the 3 days time frame, check if stats is is the query vars and if so redirect to post page. add_action(‘template_redirect’, ‘check_the_date_for_stats’); function check_the_date_for_stats() … Read more

change the post time on multiple posts

If you have the id of the posts, you can use wp_update_post and change the post_date. foreach ($postId as $id) { // random hour and time. You can also manually set these. $h = rand(1, 23); $i = rand(0, 59); $newDate = array( ‘ID’ => $id, ‘post_date’ => “2013-12-19 $h:$i:59” // [ Y-m-d H:i:s ] … Read more

Comparing Dates from custom field

Well, the exact server time/timestamp can be retrieve with current_time function. And comparing your date format, it would need to be Ymd. So combining these two thing, the proper comparison for you should be – $key = get_post_meta( $post->ID, ‘Due’, true ); $date = date(‘Ymd’, current_time(‘timestamp’) ); if( $key >= $date ) { // note … Read more

Date is wrong on ‘all posts’ page

It could be because you are not supplying post id in time parameter function. In place of the_time(‘d F’) try using echo get_the_time(‘d F’m $post->ID) because it will give you the flexibility to supply post id when you are in a loop. Reference: get_the_time Codex EDIT My bad, I guess $post variables are not being … Read more

Show different time stamp based on time

Check out human_time_diff(): if ( DAY_IN_SECONDS < ( $time = current_time( ‘timestamp’ ) ) – ( $time_post = get_the_time( ‘U’ ) ) ) echo human_time_diff( $time_post, $time ) . ‘ ago’; else the_time( ‘F j, Y at g:i a’ ); DAY_IN_SECONDS is a handy “helper” constant in WordPress, along with: MINUTE_IN_SECONDS HOUR_IN_SECONDS WEEK_IN_SECONDS YEAR_IN_SECONDS

How to get its meta_value of a specific meta_key within wp_usermeta

@Cristián Lávaque Thank you for the hints 😉 Actually I managed to resolve the issue blocking this function (show the hidden comment above). In case this would help anyone here is the final working code: function check_post_limit() { if ( current_user_can( ‘edit_posts’ ) ) { global $userdata; global $wpdb; $s2member_last_payment_time = get_user_meta( get_current_user_id(), ‘wp_s2member_last_payment_time’, true … Read more

WP Query and date format

For those who experienced the same problem, I finally found a way to do the sort. First I created an extra CMB like this : $cmb->add_field( array( ‘id’ => $prefix . ‘session_gooddatebegin’, ‘type’ => ‘hidden’, ) ); Then I created an action using save_post. If the CPT “session” is being updated, thanks to $update, I … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)