Code: unique news post meta data

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
[i]"Gemeinsam schafft man mehr."[/i]

[b][url=http://duden.de/rechtschreibung/gemeinsam#Bedeutung1]gemeinsam[/url][/b]
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

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

kweitzel


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

<?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'];
}
?>



then change the title and meta description to:


<title><?php if ($newstitle){echo $newstitle;}else{page_title();}?></title>
<meta name="description" content="<?php if ($newstitle){echo 'Website News - '.$newstitle;}else{page_description();}?>" />


This works, but i'd appreciate your comments, as I know enough php to get by.


Thanks,

malt