Rewriting search permalink

WordPress doesn’t know that you want the path /searchmyblog/ as search result base. So when it sees the a it tries to find the best match – in your case a post starting with this letter.

To fix that you could modify my code for the pagination base to change the search base:

if ( ! function_exists( 't5_search_base' ) )
{
    register_activation_hook(   __FILE__ , 't5_flush_rewrite_on_init' );
    register_deactivation_hook( __FILE__ , 't5_flush_rewrite_on_init' );
    add_action( 'init', 't5_search_base' );

    function t5_search_base()
    {
        $GLOBALS['wp_rewrite']->search_base="searchmyblog";
    }

    function t5_flush_rewrite_on_init()
    {
        add_action( 'init', 'flush_rewrite_rules', 11 );
    }
}

Now your .htaccess should work.

Leave a Comment