ruchi ruchi - 2 months ago 9
HTML Question

dynamic meta tag keywords in a dynamic page

I am working on a wordpress self-hosted website, with the standard .htaccess settings:

In the website, I have a page called "animalpage", as shown below:
http://www.example.com/animalpage.

I am using a custom page template and am processing some things, which include the use of GET variables. For instance:

if (isset($_GET=['word'])) { echo $_GET['word]; }


So,

http://www.example.com/animalpage?word=cat


will display "cat".
I need help to be able to use the word "cat" in the meta keyword of this dynamic page?

Since the meta tags can only go in head section of the page but I am only fetching GET variable in body of the page. The problem I have is how to use keyword 'cat' in meta tag in
<head>
section.

Does anyone know what I need to do so I am able to add the word "cat" (from GET parameter) in the meta tag of the dynamic page?

Answer

If I understand correctly, this is easy to impelement

<meta name="keywords" content="<?php if (isset($_GET=['word'])) { echo $_GET['word]; }  ?>" />

or another example is

<meta name="description" content="<?php if ( is_single() ) {
        single_post_title('', true); 
    } else {
        bloginfo('name'); echo " - "; bloginfo('description');
    }
    ?>" />

which means you can add anything to Meta Tag dynamically.

Hope it works for you but if not please explain more, I will help to fix that.