WordPress: Getting title tag in PHP variable

935

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 foradd_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 bywpseo_title?

865

Answer

Solution:

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

People are also looking for solutions to the problem: php - How to commission in twig?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.