WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 a hook available that lets you append or prepend text to the <title> tag in the head?

I've seen lots of posts about customizing the <title> tag, but they all involve manually adding a function inside the <title> tag. I'm looking to modify it with a hook if possible so it can be easily turned on/off in a functions.php file.

share|improve this question
up vote 1 down vote accepted

The content is modified with filters, not hooks.

To modify the <title>, use wp_title filter


  add_filter('wp_title', 'set_page_title');

  function set_page_title($orig_title) { 
    return 'Modified ' . $orig_title;
share|improve this answer
Right, thanks - I thought this was to modify the title of the post. Any pointers on how to prepend something the title using this filter? – jtotheh Sep 15 '11 at 16:35
@jtotheh I've added usage example – Maxim Krizhanovsky Sep 15 '11 at 16:39
Cheers, I'll give this a try. – jtotheh Sep 15 '11 at 16:49
Got this to work (thanks), but it changes the on-page titles when wp_title() is used elsewhere, and not just the <title> tags in the <head> - is there a filter to ONLY edit the <title> content? – jtotheh Sep 15 '11 at 20:19

yes, it's wp_title

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.