Title: sanitize_category_field
Published: April 25, 2014
Last modified: August 20, 2026

---

# sanitize_category_field( string $field, mixed $value, int $cat_id, string $context ): mixed

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#changelog)

Sanitizes data in single category key field.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#parameters)󠁿

 `$field`stringrequired

Category key to sanitize.

`$value`mixedrequired

Category value to sanitize.

`$cat_id`intrequired

Category ID.

`$context`stringrequired

What filter to use, `'raw'`, `'display'`, etc.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#return)󠁿

 mixed Value after $value has been sanitized.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#source)󠁿

    ```php
    function sanitize_category_field( $field, $value, $cat_id, $context ) {
    	return sanitize_term_field( $field, $value, $cat_id, 'category', $context );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/category.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/category.php#L276)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/category.php#L276-L278)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#related)󠁿

| Uses | Description | 
| [sanitize_term_field()](https://developer.wordpress.org/reference/functions/sanitize_term_field/)`wp-includes/taxonomy.php` |

Sanitizes the field value in the term based on the context.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/sanitize_category_field/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.3.0](https://developer.wordpress.org/reference/since/2.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fsanitize_category_field%2F)
before being able to contribute a note or feedback.