Function Reference/sanitize title

Contents

Description

Sanitizes title or use fallback title.

Specifically, HTML and PHP tags are stripped, and (in a 'save' context) accents are removed (accented characters are replaced with non-accented equivalents). Further filtering can be added via the plugin API by hooking the sanitize_title filter. If $title is empty and $fallback_title is set, the latter will be used.

Despite the name of this function, the returned value is intended to be suitable for use in a URL, not as a human-readable title.

WordPress Titles

It should return a formatted value, the output would be this:
this-long-title-is-what-my-post-or-page-might-be

Notes

The 'save' context is used most often when saving a value in the database, but is used for other purposes as well. The 'query' context is used by sanitize_title_for_query() when the value is going to be used in the WHERE clause of a query.

Source File

Related

Functions

sanitize_title() is in a class of functions that help you sanitize potentially unsafe data which allow you to pass an arbitrary variable and receive the clean version based on data type. Others include: