sanitize_title

The WordPress Core sanitize title hook.

Description

add_filter( 'sanitize_title', (string) $sanitize_title_with_dashes, (int) $int, (int) $int ); 

Parameters (3)

0. $sanitize_title_with_dashes (string) => 'sanitize_title_with_dashes'
The sanitize title with dashes.
1. $int (int) => 10
The int.
2. $int (int) => 3
The int.

Usage

To run the hook, copy the example below.
  1. $sanitize_title_with_dashes = apply_filters( 'sanitize_title', $sanitize_title_with_dashes, $int, $int ); 
  2.  
  3. if ( !empty( $sanitize_title_with_dashes ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the sanitize_title callback 
  2. function filter_sanitize_title( $sanitize_title_with_dashes, $int, $int ) { 
  3. // make filter magic happen here... 
  4. return $sanitize_title_with_dashes
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'sanitize_title', 'filter_sanitize_title', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'sanitize_title', 'filter_sanitize_title', 10, 3 ); 

Defined (2)

The filter is defined in the following location(s).

/wp-includes/default-filters.php  
  1. add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 ); 
/wp-includes/formatting.php  
  1. $title = apply_filters( 'sanitize_title', $title, $raw_title, $context );