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?
2
Answers
Ok, if we use Yoast we can get the document title by the following line:
You can use
get_the_title()
orthe_title()
, depending in which context you need it. No Yoast needed.Details here:
https://developer.wordpress.org/reference/functions/get_the_title/
https://developer.wordpress.org/reference/functions/the_title/