Using WP_Query to re-query and sort results using a date?

thanks for responses, Allowed me to find correct answer which I’ve posted below – $tickets_for_user = get_posts(array( ‘post_type’ => ‘ticket’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘event_date’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 1, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘event_date’, ‘value’ => array($today,’20991231′), ‘compare’ => ‘BETWEEN’, ‘type’ => ‘DATE’, ), array( ‘key’ => … Read more

Test date object against previous date in loop

You need something like this: $args = array( ‘post_type’ => ‘post’ ); $q = new WP_Query($args); if ($q->have_posts()) { $date=””; while ($q->have_posts()) { $q->the_post(); $m = get_post_meta($post->ID,’field_id’,true); // var_dump($m); if ($date != $m) { // if $m is a strtotime compatible string echo date(‘l’,strtotime($m)); $date = $m; } echo ‘<br>’; the_title(); echo ‘<br>’; echo str_repeat(‘-‘,200); … Read more

Calculate how much time passed comparing WordPress comment and current time

Yes, you can do that using PHP. Here’s a function from @arnorhs: $time = strtotime(‘2010-04-28 17:25:43’); echo ‘event happened ‘.humanTiming($time).’ ago’; function humanTiming ($time) { $time = time() – $time; // to get the time since that moment $time = ($time<1)? 1 : $time; $tokens = array ( 31536000 => ‘year’, 2592000 => ‘month’, 604800 … Read more

How to order custom user list columns by datetime?

I think you could simplify this a lot by using the pre_get_users hook, instead of working directly with the complicated SQL within the pre_user_query hook. Try something like: add_action( ‘pre_get_users’, function( \WP_User_Query $q ) { $qv = &$q->query_vars; if( isset( $qv[‘orderby’] ) && ‘test_date’ === $qv[‘orderby’] ) { // Custom meta query $qv[‘meta_query’] = [ … Read more

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