Title: wp_sprintf
Published: April 25, 2014
Last modified: February 24, 2026

---

# apply_filters( ‘wp_sprintf’, string $fragment, string $arg )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/wp_sprintf/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/wp_sprintf/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/wp_sprintf/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/wp_sprintf/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/wp_sprintf/?output_format=md#changelog)

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

Filters a fragment from the pattern passed to [wp_sprintf()](https://developer.wordpress.org/reference/functions/wp_sprintf/).

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/wp_sprintf/?output_format=md#description)󠁿

If the fragment is unchanged, then sprintf() will be run on the fragment.

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

 `$fragment`string

A fragment from the pattern.

`$arg`string

The argument.

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

    ```php
    $_fragment = apply_filters( 'wp_sprintf', $fragment, $arg );
    ```

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

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

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

WordPress’ implementation of PHP sprintf() with filters.

  |

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

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

## User Contributed Notes

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