Using WordPress ‘document_title_separator’ PHP filter

The document_title_separator WordPress PHP filter allows you to change the separator for the document title.

Usage

add_filter('document_title_separator', 'my_custom_title_separator');
function my_custom_title_separator($sep) {
    // your custom code here
    return $sep;
}

Parameters

  • $sep: string – Document title separator. Default ‘-‘.

More information

See WordPress Developer Resources: document_title_separator

Examples

Change the separator to a pipe character

This example changes the title separator to a pipe character (|).

add_filter('document_title_separator', 'my_custom_title_separator');
function my_custom_title_separator($sep) {
    $sep = '|';
    return $sep;
}

Change the separator to a forward slash

This example changes the title separator to a forward slash (/).

add_filter('document_title_separator', 'my_custom_title_separator');
function my_custom_title_separator($sep) {
    $sep = '/';
    return $sep;
}

Change the separator to a double colon

This example changes the title separator to a double colon (::).

add_filter('document_title_separator', 'my_custom_title_separator');
function my_custom_title_separator($sep) {
    $sep = '::';
    return $sep;
}

Change the separator to a bullet character

This example changes the title separator to a bullet character (•).

add_filter('document_title_separator', 'my_custom_title_separator');
function my_custom_title_separator($sep) {
    $sep = '•';
    return $sep;
}

Change the separator to an arrow character

This example changes the title separator to an arrow character (→).

add_filter('document_title_separator', 'my_custom_title_separator');
function my_custom_title_separator($sep) {
    $sep = '→';
    return $sep;
}