If you want to add one more table to wordpress database you need to just use the following code.
Open the functions.php file and copy paste the code.
$wordpressapi_db_version = "1.0";
global $wpdb;
global $wordpressapi_db_version;
$table_name = $wpdb->prefix . "liveshoutbox";
if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time bigint(11) DEFAULT '0' NOT NULL,
name tinytext NOT NULL,
text text NOT NULL,
url VARCHAR(55) NOT NULL,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
$welcome_name = "Mr. WordPress";
$welcome_text = "Congratulations, you just completed the installation!";
$insert = "INSERT INTO " . $table_name .
" (time, name, text) " .
"VALUES ('" . time() . "','" . $wpdb->escape($welcome_name) . "','" . $wpdb->escape($welcome_text) . "')";
$results = $wpdb->query( $insert );
add_option("wordpressapi_db_version", $wordpressapi_db_version);
}
If you want write the plugin then just convert follwing code in function and write following code in your plugin file.
register_activation_hook(__FILE__,'YOUR_FUNCTION_NAME');
Incoming search terms:
- adding table in wordpress them
- cerate table theme init wordpress
- how to create theme with new db table in wordpress
- how to develop wordpress classified plugin with custom database tables
- installed new table with wordpress themes
- wordpress create table in template
- wpdb create new table







Pingback: how can we execute the own Wordpress custom queries | wordpressapi.com