Tanmay Maity

Get WordPress Table’s column name

Leave a comment

For any reason if you need the MySQL table’s columns name in WordPress then use below code.

global $wpdb;
$table = $wpdb->prefix . 'table_name';
$column = $wpdb->get_col( "DESC " . $table, 0 );

Now you have the all columns of the table $column array. Print those

foreach( $column as $key => $value ) {
echo $value;
}

Leave a comment