I am trying to get search query string to submit custom table and count how many time these string searched
my table column
id(int), keyword(varchar), count(int)
everything i made my way but problem is when submit search form its count 4 times code following bellow.
function search_count($search) {
//table column id, keyword, count
// intial value 1, wordpress, 1
global $wpdb;
$table = "wp_search_count";
$wpdb->query("UPDATE $table SET count = count+1 WHERE keyword = '$search'");
return $search;
}
add_filter( 'get_search_query', 'search_count');
i have started count value 1 and after submit search form its should be 2 but i get 5 for count value
Please kick me on the way ...
Thanks in Advance.