It’s not an urgent issue but in Google Webmaster it shows me as having duplicate meta tags on some pages, all of which are dynamic. So for example I have:
News Content Page 1
News Content Page 2
News Content Page 3
–News Story 1
–News Story 2
–News Story 3
Now I’ve managed to sort out dynamic titles for each page, that isn’t too much of an issue but its the meta tags I can’t think of the best way to deal with.
I tried this first:
$rand=rand(1,3);
switch($rand)
{
case 1:
$keywords="compensation news, injury, work accident, road traffic accident, slip, trip, fall, fatal injury, medical negligence ";
break;
case 2:
$keywords="personal injury news, work injury, road traffic accident, slip, trip, fall, medical negligence";
break;
case 3:
$keywords="personal accident news, fatal injury, work accident, work illness, road traffic accident, broken bone, lost limb, professional negligence";
break;
}
But it doesn’t offer much variation, 10 out of 22 pages had the same Meta tags. I could obviously add more alternatives but it doesn’t seem to me as the best method.
I tried this:
$description="The latest compensation news | ".$title;
$keywordArray = array("injury","work accident","road traffic accident","slip","trip","fall","fatal injury","medical negligence","personal injury news","work injury", "personal accident news","work illness", "broken bone","lost limb","professional negligence","back injury","brain injury");
$i=1;$keywords = "compensation news";
$deadWords = array("compensation news");
while($i<=6) {
$rand = rand(0,(count($keywordArray)-1));
if(!in_array($keywordArray[$rand],$deadWords)) {
$deadWords .= $keywordArray[$rand];
$keywords .= ",".$keywordArray[$rand];
}
$i++;
}
As far as I’m aware, it may not be the cleanest way to do it but that should work. But it just throws up an error that the second input for ‘in_array’ isn’t valid, but it is an array. Searching for reasons this error pops up only indicate that it means the datatype being used isn’t an array but it at least SHOULD be an array.
So the only other alternative I can think of is to alter my database to create a tags column and adding individual tags to news stories as and when necessary. This seems like a good method to me since it creates tags specific to each news story but it doesn’t solve the issue of the same tags appearing on multiple news list pages.
So are there any members here who have experience with this? I’m leaning towards the database method though I prefer to keep it all on the PHP side if possible.