• I’m wondering if I can change the title in the address bar from a page that is using a custom template.

    E.g. from this page I’m querying data from db and I want to add something relevant to what I’ve selected in the <title>…</title>.

    I’d like to do this in my-page-template.php not in header.php

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The quick and dirty method that doesn’t require re-coding any PHP is to get the All-in-One SEO Pack plugin. Then you can override title on a page-by-page basis. Posts, too.

    Thread Starter DrLightman

    (@drlightman)

    I see that the macros that the plugin makes available are not enough for my pourpose.

    In my code I connect to an xml and based on a query that the user does in that page, some results are back.

    e.g. the user looks for a weather forecast for a particular town, I want to put the town name in the title.

    None of these cover my case:

    The following macros are supported:
        * %blog_title% - Your blog title
        * %blog_description% - Your blog description
        * %page_title% - The original title of the page
        * %page_author_login% - This page's author' login
        * %page_author_nicename% - This page's author' nicename
        * %page_author_firstname% - This page's author' first name (capitalized)
        * %page_author_lastname% - This page's author' last name (capitalized)

    I need something like:

    set_title($town_name.’ – Foo Blog’);

    I’m already coding the template, I’m not araid of writing functions if it has to be done.

    Doc, you’re very advanced… I like that! Probably ahead of me, in fact. I don’t quite know… if I were pursuing it, one place I’d look would be custom fields. I’m pretty sure you could set one (or more) up and then access that in your template code.

    Since you’re obviously adept, reading Codex should be a picnic for you.
    http://codex.wordpress.org/Custom_Fields
    Someone else might chime in…

    good luck,
    Dave

    Thread Starter DrLightman

    (@drlightman)

    lol, very advanced, not really 🙂

    thanks anyway! advanced as I am I didn’t know the plugin all-in-seo pack 🙁

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘changing page title (browser) from inside template’ is closed to new replies.