Jump to content

Dynamic title tags header.php


Recommended Posts

Hello group,


Apologies if this has been asked. I have a site that is generating pages like this:

I want to create dynamic meta data in the header.php
<title><?php echo $pageTitle; ?></title>
<meta name="description" content="<?php echo $pageDescription; ?>">
I'm new to the more advanced functions of php so my question is... where are the values for $pageTitle and $pageDescription stored if every page seems to reference index.php as the page (although there might be dynamic functionality within this page I suppose)? I could understand if the pages referenced were all different like products.php, services.php, etc. I'm looking at the URLs generated on the site and am trying to figure this out.
Link to comment
Share on other sites

It is possible that the data is in a database. So, if for example we are displaying a product page the rwo in the database for the product might have fields like this:

Product_name: Flying pig.
Price: 9.99
Product_desc: A pig with wings.
meta_desc: The only place to buy this. Not yet available. Will become available when pigs fly.
keywords: OMG, Way Cool, pig, pork, feathers

You first read the db, then render the page.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.