Change the Search Base in a multi language wordpress

I found the solution. I had to flush rules after I change the search base with the code on the edited question. Here is the final code:

$lang = get_bloginfo("language");
if ( $lang == 'de-DE' ) {
    add_action('init', 'search_base_german');
    function search_base_german() {
        $search_slug = 'suche'; // change slug name
        $GLOBALS['wp_rewrite']->search_base = $search_slug;
        $GLOBALS['wp_rewrite']->flush_rules();
    }
}

Leave a Comment