So depending on your theme, you’ll need to take a different approach. By the sounds of it, you’re using a theme that adds WordPress theme support for title-tag
e.g. twentynineteen. In this case, your code would look like this:
function add_dynamic_title( $aTitleParts ) {
if ( isset( $aTitleParts[ 'title' ] ) && $aTitleParts[ 'title' ] == 'Details' ) {
$aTitleParts[ 'title' ] = $_GET[ 'Name' ];
}
return $aTitleParts;
}
add_filter( 'document_title_parts', 'add_dynamic_title', 20 );
This filter uses an array where it contains, amongst other things, a key title
and perhaps tagline
. So in this case you set the array key value for title
to whatever you’d like and return the whole array.