• When I make a search on my website, the browser goes to this URL:

    https://gameshock.vg/?s=[search term]

    Is there a way to customize just one page of a particular search term, to show something different from the others? Ie: when someone searchs “balloon”, instead of leading to the results of the word “balloon” it takes you to a different page.

    I want to make an easter egg on my website ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • This could be achieved by correctly adding a 301 redirect to your .htaccess file, through a PHP script, a redirect plugin, or perhaps even using a host provided url redirect tool.

    I did some research on this after writing my response…several things I tried (and read) did not work.

    Attempting on one site, what I thought should wotk did not, but that site uses a theme that adds an action hook to get_search_query so I just tried on a site that uses the default (child) theme.

    Add this to functions.php (best in a Child Theme):

    add_action('template_redirect', 'redirect_my_term' );function redirect_my_term() {if (is_search()) {
     	if (preg_match('/\b[search term]\b/i', get_search_query()) == TRUE){
    		wp_redirect(home_url("/your_slug/")); die(); }}
    	}

    Note: [search term] = term, do not leave brackets.
    /your_slug/ = the slug for the page including both /’s

    Is working here (my site, linked on left, with this information), search for qqvxy and you will end up at /category/security/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customize a search page result’ is closed to new replies.