Filter
uncanny-automator-pro
document_title_separator
This filter is documented in https://developer.wordpress.org/reference/hooks/document_title_separator/ */ Filters the separator used between document titles, allowing customization when Learndash is active.
add_filter( 'document_title_separator', $callback, 10, 1 );
Description
This filter allows developers to change the separator used in document titles, particularly within LearnDash. Modify the default hyphen to customize how titles are displayed, offering flexibility in presentation and branding across your WordPress site.
Usage
add_filter( 'document_title_separator', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
// Change the document title separator from '-' to ' | ' for better readability
add_filter( 'document_title_separator', 'my_custom_document_title_separator', 10, 1 );
/**
* Custom function to change the document title separator.
*
* @param string $separator The current document title separator.
* @return string The modified document title separator.
*/
function my_custom_document_title_separator( $separator ) {
// If the current separator is the default '-', change it to ' | '.
// Otherwise, keep the existing separator.
if ( $separator === '-' ) {
return ' | ';
}
return $separator;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/learndash/helpers/learndash-pro-helpers.php:711
ob_start();
$cert_args['cert_title'] = $cert_args['cert_post']->post_title;
$cert_args['cert_title'] = strip_tags( $cert_args['cert_title'] );
/** This filter is documented in https://developer.wordpress.org/reference/hooks/document_title_separator/ */
$sep = apply_filters( 'document_title_separator', '-' );
/**
* Filters username of the user to be used in creating certificate PDF.
*
* @param string $user_name User display name.
* @param int $user_id User ID.
* @param int $cert_id Certificate post ID.