Title: wp_required_field_indicator
Published: November 2, 2022
Last modified: August 20, 2026

---

# wp_required_field_indicator(): string

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#wp--skip-link--target)

Assigns a visual indicator for required form fields.

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

 string Indicator glyph wrapped in a `span` tag.

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

    ```php
    function wp_required_field_indicator() {
    	/* translators: Character to identify required form fields. */
    	$glyph     = __( '*' );
    	$indicator = '<span class="required">' . esc_html( $glyph ) . '</span>';

    	/**
    	 * Filters the markup for a visual indicator of required form fields.
    	 *
    	 * @since 6.1.0
    	 *
    	 * @param string $indicator Markup for the indicator element.
    	 */
    	return apply_filters( 'wp_required_field_indicator', $indicator );
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_required_field_indicator’, string $indicator )](https://developer.wordpress.org/reference/hooks/wp_required_field_indicator/)

Filters the markup for a visual indicator of required form fields.

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

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

Retrieves the translation of $text.

  | 
| [esc_html()](https://developer.wordpress.org/reference/functions/esc_html/)`wp-includes/formatting.php` |

Escaping for HTML blocks.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#)

| Used by | Description | 
| [wp_required_field_message()](https://developer.wordpress.org/reference/functions/wp_required_field_message/)`wp-includes/general-template.php` |

Creates a message to explain required form fields.

  | 
| [wp_media_insert_url_form()](https://developer.wordpress.org/reference/functions/wp_media_insert_url_form/)`wp-admin/includes/media.php` |

Creates the form for external url.

  | 
| [get_media_item()](https://developer.wordpress.org/reference/functions/get_media_item/)`wp-admin/includes/media.php` |

Retrieves HTML form for modifying the image attachment.

  | 
| [get_compat_media_markup()](https://developer.wordpress.org/reference/functions/get_compat_media_markup/)`wp-admin/includes/media.php` |

Retrieves the media markup for an attachment.

  | 
| [comment_form()](https://developer.wordpress.org/reference/functions/comment_form/)`wp-includes/comment-template.php` |

Outputs a complete commenting form for use within a template.

  |

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/?output_format=md#comment-content-7606)
 2.   [Travis Jeans](https://profiles.wordpress.org/travisjeans/)  [  1 month ago  ](https://developer.wordpress.org/reference/functions/wp_required_field_indicator/#comment-7606)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_required_field_indicator%2F%23comment-7606)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_required_field_indicator%2F%23comment-7606)
 4. To save someone else the trouble of trying to figure out how to change asterisks(*)
    as the required field indicator to the word (required) for accessibility reasons,
    here is one which works with WordPress 6.9.4 (and probably others). It is in a 
    span element (WP site formatting removes spans so put it around the (required) 
    in `$required_indicator` so you need to add it) so you can restyle the size of 
    the text in CSS if you like.
 5.     ```php
        /* Change the required field indicator from an asterisk to (required) */
        function wpdocs_add_custom_required_indicator() {
            $required_indicator = '(required)';
            return $required_indicator;
        }
        add_filter( 'wp_required_field_indicator', 'wpdocs_add_custom_required_indicator' );
        ```
    
 6. This also requires changing `wp_required_field_message()` so I will add a note 
    to that hook as well.
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_required_field_indicator%2F%3Freplytocom%3D7606%23feedback-editor-7606)

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