I am sanitizing a text field input via a custom WordPress Setting API page like this...

public function current_issue_sanitize($input) {
    $sanitary_values = array();
    if ( isset( $input['episode'] ) ) {
        $sanitary_values['episode'] = sanitize_text_field( $input['episode'] );

    return $sanitary_values;

This is working well but I am now trying to sanitize and integer, is there a sanitize_text_field equivalent for numbers?


1 Answer 1


If the integer should be a positive number, you can use absint(). See: https://codex.wordpress.org/Function_Reference/absint

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.