Skip to content
Advertisement

How to get document (seo) title of specific page in WordPress

I don’t mean the page or post title but the title between <title> and </title>. The so-called SEO or document title.

I’ve just googled but found nothing. I only know to get document title of current page we can use wp_get_document_title(). But how to get document title of specific page by its post or category ID for example?

Advertisement

Answer

Ok, if we use Yoast we can get the document title by the following line:

$seo_title = get_post_meta($post_id, '_yoast_wpseo_title', true);
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement