Update existing post times to random times?

This is the part that is responsible for random date: //* Generate a random date between January 1st, 2015 and now $random_date = mt_rand( strtotime( ‘1 January 2015’ ), time() ); So you need to change it. And if you want to randomize only the time part, then this is one way to achieve that: … Read more

Count time from registration date to today

Just gave an example of how to do it: $today_date = new DateTime( date( ‘Y-m-d’, strtotime( ‘today’ ) ) ); $register_date = get_the_author_meta( ‘user_registered’, get_current_user_id() ); $registered = new DateTime( date( ‘Y-m-d’, strtotime( $register_date ) ) ); $interval_date = $today_date->diff( $registered ); if( $interval_date->days < 31 ) { echo ‘With us ‘ . $interval_date->format(‘%d days’); … Read more

How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?

get_post() and get_post_meta() should work to collect the data and array_multisort() should be able to sort it into ascending order. // Query the database to get the posts from your post types $project_args = array( ‘post_type’ => ‘projects’, “numberposts” => -1 ); $task_args = array( ‘post_type’ => ‘tasks’, “numberposts” => -1 ); $material_args = array( … Read more

Apply filters on date format

As per the code reference the_time filter recieves two parameters – $get_the_time and $format. You can use the latter to determine which formatting option to use. add_filter( ‘the_time’, ‘changer_date_format’, 10, 2 ); function changer_date_format( $ladate, $format ) { global $post; if ( ‘d M’ === $format ) { return get_post_time( get_option( ‘date_format’ ), false, $post, … Read more

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