![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/imgs/post01.jpg)
How to create a table with wordpress custom plugin?
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/li_st1.png)
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/li_st1.png)
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/li_st1.png)
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/imgs/kand5.png)
Create a table with WordPress custom plugin
<?php function my_first_plugin_code(){ /* create table */ global $wpdb; $charset_collate = $wpdb->get_charset_collate(); $table_name = $wpdb->prefix . "myplugintable"; $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, name tinytext NOT NULL, text text NOT NULL, url varchar(55) DEFAULT '' NOT NULL, PRIMARY KEY (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql );
![](https://wpdevkit.in/wp-content/themes/twentytwenty-child/author.jpg)
POST COMMENTS