We have a script that displays the Yoast SEO title and if no SEO title exists, then we just default to the page title:
function replace_wp_title_with_yoast_seo_title($title) {
$yoast_title = get_post_meta(get_the_ID(), '_yoast_wpseo_title', true);
if (!empty($yoast_title)) {
// If Yoast SEO has a title, use it
return $yoast_title;
}
// If Yoast SEO title is not available or Yoast SEO is not active, use the original title
return $title;
}
add_filter('pre_get_document_title', 'replace_wp_title_with_yoast_seo_title', 10);
But in browser we something like this for the title: Marijuana Users May Eat More—But Weigh Less %%page%% %%sep%% %%sitename%%
Any ideas on why this is doing this?