WordPress: Getting Title Tag In PHP Variable

- 1 answer

I am using Yoast SEO for SEO on the website. In my header file I have added

<title><?php wp_title( '|', true, 'right' ); ?></title>

I have also added <?php wp_head(); ?> in header. Also enabled Force rewrite titles but still the title tag which I have added in page while editing it, in SEO Snippet is not displaying on webpage.

I have not added support for add_theme_support( 'title-tag' ); - Adding it and removing title tag from head also won't make any difference

So my question here is how I can grab the title tag Added in snippet and at list echo it out in page. On API for Yoast they have listed some hooks and filters but their are no examples.

Can get it by wpseo_title?



Make sure to add add_theme_support( 'title-tag' ); in functions.php and remove any <title></title> tags from header.php