Get Users’ Search Terms

Home/Wordpress tricks/Get Users’ Search Terms

Get Users’ Search Terms

This code is very useful when you want to show the users posts related to their search. Some blog would show pop ups at the bottom using these search terms and will take users to other posts of their blog. Here is a code snippet to get the search terms of your users.

<?php <br ?> $refer = $_SERVER["HTTP_REFERER"];
if (strpos($refer, "google")) {
$refer_string = parse_url($refer, PHP_URL_QUERY);
parse_str($refer_string, $vars);
$search_terms = $vars['q'];
echo 'Welcome Google visitor! You searched for the following terms to get here: ';
echo $search_terms;
};
?&gt;

Yumna Tatheer

Yamna Tatheer is a WordPress Plugin developer and a Top-Rated Upwork professional. She is a part-time blogger from Lahore and loves to write about wordpress and freelance industry.

More Posts

Follow Me:
Facebook

About the Author:

Yamna Tatheer is a Wordpress Plugin developer and a Top-Rated Upwork professional. She is a part-time blogger from Lahore and loves to write about wordpress and freelance industry.

Leave A Comment