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

---

# convert_chars( string $content, string $deprecated = ” ): string

## In this article

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

Converts lone & characters into `&#038;` (a.k.a. `&amp;`)

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

 `$content`stringrequired

String of characters to be converted.

`$deprecated`stringoptional

Not used.

Default:`''`

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

 string Converted string.

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

    ```php
    function convert_chars( $content, $deprecated = '' ) {
    	if ( ! empty( $deprecated ) ) {
    		_deprecated_argument( __FUNCTION__, '0.71' );
    	}

    	if ( str_contains( $content, '&' ) ) {
    		$content = preg_replace( '/&([^#])(?![a-z1-4]{1,8};)/i', '&#038;$1', $content );
    	}

    	return $content;
    }
    ```

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

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

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

Marks a function argument as deprecated and inform when it has been used.

  |

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

Displays Site Icon in atom feeds.

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

Displays Site Icon in RSS2.

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

Formats text for the rich text editor.

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

Retrieves RSS container for the bloginfo function.

  |

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

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

## User Contributed Notes

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