The rest api did not process the context query parameter correctly – fix

The rest api did not process the context query parameter correctly

After a fresh installation of the wordpress installation, while changing from default plain permalink structure, I couldn’t edit or write any post. This was only possible after installing the classic WordPress editor. The reason for this was an error in the API configuration. I found a solution on the Internet by adding the following rule to the webserver configuration:

location ~ ^/blog/wp-json/ {
   rewrite ^/blog/wp-json/(.*?)$ /blog/?rest_route=/$1 last;
}

… however, this rule didn’t work for me as the ‘wp-json’ folder and its contents was missing in the WordPress installation folder.

A much simpler way to eliminate this error was to edit the file ‘wp-includes/rest-api.php’ on line 327:

- return apply_filters( 'rest_url_prefix', 'wp-json' );
+ return apply_filters( 'rest_url_prefix', '?rest_route=' );

After editing this file, you can easily edit or write posts in the current version of the WordPress editor as well as change the permalinks to any structure you want and the warning in the site health status panel should disappear.

worpress health status pass

Leave a Reply

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