WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can I use PHP in a page to change title, description and keywords (4 posts)

  1. Phacelia
    Member
    Posted 1 year ago #

    I have the Exec PHP plugin and am running a PHP script inside pages to let users lookup things in a database (not the WP database). The user enters a search string and gets a list which comes out of the database.
    Would it be possible to then (on the fly) also change the <title> <description> and <keywords> of the result page, so that it reflects the content of the page? For example if the user searches with the word "fish", then the <title> of the page should become something like "Search results for: Fish", and the word "fish" should of course be in the list of keywords.

  2. Phacelia
    Member
    Posted 1 year ago #

    Was it a stupid question? or does nobody have an answer?

  3. jnhghy
    Member
    Posted 1 year ago #

    Hi Phacelia,
    The question is not stupid but if you use a plugin then in most cases at witch I can think at this point you'll get the result only after the header was rendered so to change the page title you'll probably have to use some extra html and javascript to change the title.
    Javascript/jquery can change the title of a page after it was randerd some info here.
    Regards

  4. Phacelia
    Member
    Posted 1 year ago #

    Thanks, I will try that solution.

Topic Closed

This topic has been closed to new replies.

About this Topic