• Resolved Pepozzo

    (@pepozzo)


    Hello!

    Do you know if there is a plugin that could link to a specific page when a search is made?

    For example: i’ve a page called “Product 1”, if someone search “Product 1” wordpress will retrieve a list of pages with that terms, i would like that when a user will search “Product 1”, it will be automatically redirected to http://www.mysite.com/product-1 page.

    Is it possible? Any plugin?

    Thanks in advance

Viewing 1 replies (of 1 total)
  • Thread Starter Pepozzo

    (@pepozzo)

    Solved with this code added to my function.php theme:

    function redirect_search() {
    	if (is_search() && !empty($_GET['s'])) {
    		wp_redirect(home_url("/").urlencode(get_query_var('s')));
    		exit();
    	}
    }
    add_action('template_redirect', 'redirect_search' );
Viewing 1 replies (of 1 total)
  • The topic ‘Search links to a specific page’ is closed to new replies.