$_SERVER global varto create page meta details. Naturally, it did not discover a URL for mapped pages, so it created the content using information from the homepage, causing the template to break.
global $post;method after a tag is closed (which also means the
wp_headaction ends), we are now re-checking
wp_headwith a very late priority (99). Then, we are checking if Yoast is active, and if
global $post;has changed, we bring back the right post value.