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

---

# wp_sprintf_l( string $pattern, array $args ): string

## In this article

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

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

Localizes list items before the rest of the content.

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

The ‘%l’ must be at the first characters can then contain the rest of the content.
The list items will have ‘, ‘, ‘, and’, and ‘ and ‘ added depending on the amount
of list items in the $args parameter.

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

 `$pattern`stringrequired

Content containing `'%l'` at the beginning.

`$args`arrayrequired

List items to prepend to the content and replace `'%l'`.

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

 string Localized list items and rest of the content.

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

    ```php
    function wp_sprintf_l( $pattern, $args ) {
    	// Not a match.
    	if ( ! str_starts_with( $pattern, '%l' ) ) {
    		return $pattern;
    	}

    	// Nothing to work with.
    	if ( empty( $args ) ) {
    		return '';
    	}

    	/**
    	 * Filters the translated delimiters used by wp_sprintf_l().
    	 * Placeholders (%s) are included to assist translators and then
    	 * removed before the array of strings reaches the filter.
    	 *
    	 * Please note: Ampersands and entities should be avoided here.
    	 *
    	 * @since 2.5.0
    	 *
    	 * @param array $delimiters An array of translated delimiters.
    	 */
    	$l = apply_filters(
    		'wp_sprintf_l',
    		array(
    			/* translators: Used to join items in a list with more than 2 items. */
    			'between'          => sprintf( __( '%1$s, %2$s' ), '', '' ),
    			/* translators: Used to join last two items in a list with more than 2 times. */
    			'between_last_two' => sprintf( __( '%1$s, and %2$s' ), '', '' ),
    			/* translators: Used to join items in a list with only 2 items. */
    			'between_only_two' => sprintf( __( '%1$s and %2$s' ), '', '' ),
    		)
    	);

    	$args   = (array) $args;
    	$result = array_shift( $args );
    	if ( 1 === count( $args ) ) {
    		$result .= $l['between_only_two'] . array_shift( $args );
    	}

    	// Loop when more than two args.
    	$i = count( $args );
    	while ( $i ) {
    		$arg = array_shift( $args );
    		--$i;
    		if ( 0 === $i ) {
    			$result .= $l['between_last_two'] . $arg;
    		} else {
    			$result .= $l['between'] . $arg;
    		}
    	}

    	return $result . substr( $pattern, 2 );
    }
    ```

[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#L5333)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/formatting.php#L5333-L5386)

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

 [apply_filters( ‘wp_sprintf_l’, array $delimiters )](https://developer.wordpress.org/reference/hooks/wp_sprintf_l/)

Filters the translated delimiters used by [wp_sprintf_l()](https://developer.wordpress.org/reference/functions/wp_sprintf_l/).

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

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

Retrieves the translation of $text.

  | 
| [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.

  |

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

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

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

 1.   [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_sprintf_l/?output_format=md#comment-content-4118)
 2.    [Rami Yushuvaev](https://profiles.wordpress.org/ramiy/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/wp_sprintf_l/#comment-4118)
 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_sprintf_l%2F%23comment-4118)
     Vote results for this note: 1[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_sprintf_l%2F%23comment-4118)
 4.  The “`%l`” placeholder turns any array into a comma separated list.
 5.  **This code:**
 6.  `wp_sprintf( __( 'My numbers: %l' ), array( 1, 2, 3, 4, 5 ) );`
 7.  **Returns this:**
 8.  `My numbers: 1, 2, 3, 4, and 5`
 9.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_sprintf_l%2F%3Freplytocom%3D4118%23feedback-editor-4118)

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