Jump to content

Dynamic title tags header.php


TechGirl00

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
ex:
<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.
 
Thanks.
 
Link to comment
https://forums.phpfreaks.com/topic/290236-dynamic-title-tags-headerphp/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.