How to properly sanitize/secure a WP Query coming from the front end

The only way to do this would be to whitelist the allowed arguments, being very careful to limit them so as not to introduce an DOS attack vector.

Having said that, this is not how most infinite scroll implementations are built, and you may have better results relying on the WP API rest api instead for those kinds of requests

Leave a Comment