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.


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;
  • 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 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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