Jump to content

Dynamic meta description and title


kade119

Recommended Posts

Define them as variables before including the header page, and just echo them out in the included script.

 

<?php
$title = "Some String of stuff";
$desc = "Some other string of stuff";
include('header.php');
//body 
include('footer.php');
?>

With meta-tags always a good idea to set default options because as your website grows there's a good chance they will get over looked.  So use a conditional like:

 

if (!isset($title)){
echo '<title>Default Page Title</title>';
} else {
echo '<title>' . $title . '</title>';
}

 

You might also want to consider using the database to drive the meta tags - particularly if you have any form of catalogue.

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.