I’m developing a Custom Theme for a WordPress site and I want to use WordPress Core Data Validation Functions to validate the info from some forms.
Every time I try to use the sanitize_text_field()
function I get this error:
Fatal error: Call to undefined function sanitize_text_field().
I’ve read many posts with similar issues, specially using $wpdb
, but none of them seem to work.
The file in which I’m trying to use this sanitation functions is inside my theme directory, in case that piece of info helps solve the mystery.
I’ve seen some posts talking about including the wp-load.php and formatting.php files but none of my attempts has worked yet.
Ok, I kept searching and found a solution, adding the next line of code to the beginning of my file solved my problem:
I hope this helps someone else too.