Forums

Dynamic keywords in title and slug: how to customize with variable (1 post)

  1. tim1kt
    Member
    Posted 4 months ago #

    I'd like to be able to customize the title and slug of a WordPress page or post depending on a variable passed by a query string.

    So for instance I have a page which currently has the slug
    http://www.mysite.com/my-current-slug/

    When someone follows a link to
    http://www.mysite.com/my-current-slug/?keyword

    I'd like it to resolve (just for this visit to this page) to something like
    http://www.mysite.com/keyword

    I've looked at the info on template tags here
    http://codex.wordpress.org/Stepping_Into_Template_Tags

    and I can see that there are tags called (eg) the_title(). What I can't see is

    1. How to temporarily change the contents of that variable so that on this page alone (and for just this view of the page) a different page title is shown

    2. Where to put the relevant PHP code that does the work. Obviously I'd write <?php and then ?>, but I assume I can't write the code into the page title field.

    Can anyone help? Thanks in advance!

Reply

You must log in to post.

About this Topic