Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

query

prefix . \’udp_statistics_searchs\’;

$sql = \”CREATE TABLE $table_name (
id int(11) NOT NULL AUTO_INCREMENT,
search varchar(255) DEFAULT NULL,
UNIQUE KEY id (id)
);\”;

require_once( ABSPATH . \’wp-admin/upgrade.php\’ );

dbDelta($sql);
}

add_action( \’wp_footer\’, \’udp_get_search\’ );

function udp_get_search()
{
if(isset($_GET[\”s\”]) && !empty($_GET[\”s\”]))
{
global $wpdb;
$table_name = $wpdb->prefix . \’udp_statistics_searchs\’;

$wpdb->insert(
$table_name,
array(
\’search\’ => esc_attr( $_GET[\”s\”] )
)
);
}
}

register_deactivation_hook(__FILE__, \’udp_remove_tables\’ );

function udp_remove_tables()
{
global $wpdb;

$table_name = $wpdb->prefix . \’udp_statistics_searchs\’;

$sql = \”DROP table IF EXISTS $table_name\”;

$wpdb->query($sql);
}

// WP_Query arguments
$args = array(
);

// The Query
$query = new WP_Query( $args );