• Just wondering what the simplest way to rewrite the page title in a plugin is. Essentially, I just want the title to pass through this function so that I can check the page to see if I want to change it. If I don’t want to change it – I’d like to leave it as is, otherwise I’d like to do some things to it.

    I think this might have something to do with using a filter to get all of the head section and replace the title with my own, or something of the like, but I’m not sure which is why I’m asking here.

    Also note that “All In One SEO Plugin” is installed on the site, so I’d need a way to get back at the title after that is done processing it.

    Any help is greatly appreciated. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter garry12

    (@garry12)

    bump

    There’s no need to be so impatient – it might put some people off answering.

    You need to add a filter for the_title

    http://codex.wordpress.org/Function_Reference/add_filter

    In the filter, you’ll probably want to check that you’re in the loop (as the_title is used in the page list widget too, and you’ll change the title of that page in the menu as well as on the page if you don’t check for it). Use

    if ( in_the_loop() ) { .... }

    for that.

    the_title is passed to the filter as an argument. You can do what you want to it and return the new title.

    Reading through your original post again, i’m not sure which title you’re referring to. The page title or the “title” tag in the header. My solution will change the page title (in the Worpress sense of “page”).

    If you’re talking about the header title, then wp_title is what you’ll need to filter – and you can ignore what i said about being in the loop.

    There’s a list of template tags that you could filter at http://codex.wordpress.org/Template_Tags

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Rewriting the title..’ is closed to new replies.