WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way of generating the title tag of a page from the content of an H1 tag on my wordpress page? I've got some dynamically generated content pulled in via an external XML feed and and at the moment, as the page isn't physically generated via the wordpress admin system and is just using a template, the page title is just staying the same regardless of the content.

However, I was just wondering whether it would be possible in php, to grab the content of an H1 on a page and generate the title tag from that?

Any tips / advice would be greatly appreciated :)


share|improve this question
up vote 0 down vote accepted

If you can pull the XML feed before the Title gets set then you could easily use information from the XML feed (and thus the H1) in the title.

I guess you need to ask yourself these questions:

  • Can I pull the XML before the title is processed?

  • When creating the H1 are there any other dependencies that are only available after the Title is created preventing you from doing this before header.php

If you can then you just need to add your code and some conditional statements to the Title tag within header.php

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.