WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wptexturize

Description

This returns given text with transformations of quotes to smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol.

Text enclosed in the tags <pre>, <code>, <kbd>, <style>, <script>, and <tt> will be skipped. This list of tags can be changed with the 'no_texturize_tags' filter.

Text in the '[code]' shortcode will also be ignored. The list of shortcodes can be changed with the 'no_texturize_shortcodes' filter.

The entire function can be turned off with the 'run_wptexturize' filter.

Usage

 <?php wptexturize$text ); ?> 

Parameters

$text
(string) (required) The text to be formatted.
Default: None

Return Values

(string) 
The string replaced with html numeric character references.

Notes

Opening and closing quotes can be customized in a WordPress translation file. Here are some of the text transformations:

source text transformed text symbol name
"---" "—" em-dash
" -- " "—" em-dash
"--" "–" en-dash
" - " "–" en-dash
"..." "…" ellipsis
`` opening quote
"hello “hello opening quote
'hello ‘hello opening quote
'' closing quote
world." world.” closing quote
world.' world.’ closing quote
" (tm)" " ™" trademark symbol
1234" 1234″ double prime symbol
1234' 1234′ prime symbol
'99 ’99 apostrophe before abbreviated year
Webster's Webster’s apostrophe in a word
1234x1234 1234×1234 multiplication symbol


There is a small "cockney" list of transformations, as well. They can be replaced if the variable $wp_cockneyreplace is defined and contains an associative array with the keys containing the source strings and the values containing the transformed strings. By default the following strings will be transformed:

  • 'tain't
  • 'twere
  • 'twas
  • 'tis
  • 'twill
  • 'til
  • 'bout
  • 'nuff
  • 'round
  • 'cause

Change Log

Since: 0.71

In 4.0: wptexturize() and _wptexturize_pushpop_element() were significantly revised to improve performance and to resolve many bugs. This version also added the run_wptexturize filter to allow a theme or plugin to permanently disable this feature.

Source File

wptexturize() is located in wp-includes/formatting.php.

Related

See also index of Function Reference and index of Template Tags.