Custom post type column which compares dates?

I solved it:

  if ( 'visitor_active' == $column_name ) {
    $start_date = get_post_meta( $post_id, 'visitor-start-date', true );
    $end_date = get_post_meta( $post_id, 'visitor-end-date', true );
    $current_time = current_time( 'timestamp' );
      if ($start_date < $current_time && $end_date > $current_time) {
        echo '<span class="dashicons dashicons-yes" style="color:#75c377;"></span>';
      }
      else {
        echo '<span class="dashicons dashicons-no" style="color:lightgray;"></span>';
      }
  }

Don’t know if this is the best way to do it though?

Leave a Comment