Skip to content

Instantly share code, notes, and snippets.

@platoosom
Created April 17, 2020 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save platoosom/2d5c4f1d7aedf5f08ab05c1a70f84a41 to your computer and use it in GitHub Desktop.
Save platoosom/2d5c4f1d7aedf5f08ab05c1a70f84a41 to your computer and use it in GitHub Desktop.
Wordpress สร้างฐานข้อมูลขึ้นมาใหม่ถ้าหากมันไม่มี
/**
* Create custom table to keep import article url
*/
add_action('init', 'topgear_create_import_exists_table');
function topgear_create_import_exists_table()
{
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->base_prefix}imported_articles` (
ID bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
slug varchar(255) NOT NULL,
PRIMARY KEY (ID)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment