Check this out
function custom_title($title_parts) {
$title_parts['title'] = "Page Title";
return $title_parts;
}
add_filter( 'document_title_parts', 'custom_title' );
In custom_title
, $title_parts
contains ‘title’, ‘page’ (the pagination), ‘tagline’ (the slogan you specified) and ‘site’. Set “title” the way you like.