WebsiteBaker Support (2.8.x) > Templates, Menus & Design
Code: unique news post meta data
(1/1)
malt:
Hi,
I've come up with a solution to resolve the issue of news posts having duplicate titles & meta tag descriptions, which was something i was being nagged about by google webmaster tools.
The code below just takes the title of the news post and puts it as the title and meta tag description. Then the top level news page uses the description from the page settings.
In your template index.php file (i have one just for news to minimise the use of the php code) just before the <title> line
--- Code: ---<?php
if (is_numeric($post_id)){
$newstuff = $database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = $post_id");
$newsrow = $newstuff->fetchRow();
$newstitle = $newsrow['title'];
}
?>
--- End code ---
then change the title and meta description to:
--- Code: ---<title><?php if ($newstitle){echo $newstitle;}else{page_title();}?></title>
<meta name="description" content="<?php if ($newstitle){echo 'Website News - '.$newstitle;}else{page_description();}?>" />
--- End code ---
This works, but i'd appreciate your comments, as I know enough php to get by.
Thanks,
malt
kweitzel:
Have you tried this solution: http://WebsiteBaker.at/wb/module/simple-pagehead.html
cheers
Klaus
malt:
I did try it, but all it did for me was remove the meta data completly, where i want something to be there, but be unique.
Thanks,
malt
Stefek:
Hello,
the Snippet Klaus offered you should work as excepted, if not, you did something wrong, I guess.
In the normal case it will replace the <title> with the Newstitle and the description with the brief-description of your News-Item.
So I wonder that your fields are empty.
But your solution is not bad - the only thing is, its not really unique, for you have the same keywords for title and description, don't you? :wink:
Regards,
Stefek
Navigation
[0] Message Index
Go to full version