How do I count columns on a custom WPDB query?
Under straight mysql core functions you would use mysql_num_fields, but through $wpdb (wordpress database object), I found the following worked for me. $result = $wpdb->get_results(‘DESCRIBE ‘.$table,ARRAY_A); $columns = array(); foreach($result as $row) { $columns[] = $row[‘Field’]; } $num_fields = count($columns);