Search Redirector

Basically, Plugin causes WP to ignore any ?s= search requests, and instead, only performs searches on ?search= instead.

It does not modify the search forms, the theme will need to be changed to direct requests at the correct name. Could easily be placed in a themes functions.php instead too.

<?php
/*
Plugin Name: Search Redirector
Plugin URI: http://dd32.id.au/test-plugin/
Description: Redirects ?s= to ?search=
Version: 1.0
License: Public Domain; Do what ever you please
Author: DD32
Author URI: http://dd32.id.au/
*/

add_action('parse_request', 'search_request');
function search_request($wp){
    $wp->query_vars['s'] = '';
    if( !empty($wp->query_vars['search']) )
        $wp->query_vars['s'] = $wp->query_vars['search'];
}

add_filter('query_vars', 'search_queryvars' );
function search_queryvars( $qvars ){
    $qvars[] = 'search';
    return $qvars;
}

?>

Rather simple really..

0 thoughts on “Search Redirector

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>