Rewrite URL for Search + Special Characters / Umlaute

I want prettier search urls, like /suche/Danach+suche+ich/ So here is my code:

add_filter("rewrite_rules_array", function($rules) {

    $newRules = array();
    $newRules["suche/(.+)/?$"] = 'index.php?s=$matches[1]';

    $merged = array_merge($newRules, $rules);

    return $merged;
});

/?s=Testbeitrag works

/suche/Testbeitrag same result, nice

/?s=Ümlautetest works, nice!

/suche/Ümlautetest doesn't work

I still get to the right page, but there are no posts printed out–

.


EDIT: it appears that the issue is in my archive.php

I want to change the number of posts for all queries going to archive.php in order to prepare infinite scroll mechanics.

global $query_string;

$posts = query_posts($query_string.'posts_per_page=150'); 
// the main $wp_query doesn't seem to have "numberposts", so "posts_per_page" it is

When I comment out this line, the /suche/Ümlautetest gives me the expected results.

But Why does this line only affects the results with /suche/Ümlautetest?

Topic htmlspecialchars-decode url-rewriting Wordpress search

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.