Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Conditional document < title > separator

Modify the separator for the document title, based on wordpress conditional tags.

function custom_document_title_separator( $sep ) {
	
	// Change separator for singular blog post
	if( is_singular( 'post' ) ) {
		$sep = '|';
	}
	
	return $sep;
	
}
add_filter( 'document_title_separator', 'custom_document_title_separator', 10, 1 );