WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.

Donate with PayPal buttonSpenden mit dem PayPal-Button

  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Code: unique news post meta data
  • Print
Pages: [1]   Go Down

Author Topic: Code: unique news post meta data  (Read 3536 times)

malt

  • Guest
Code: unique news post meta data
« on: June 10, 2010, 12:04:08 PM »
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: [Select]
<?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[&#39;title&#39;];
}
?>


then change the title and meta description to:

Code: [Select]
<title><?php if ($newstitle){echo $newstitle;}else{page_title();}?></title>
<meta name="description" content="<?php if ($newstitle){echo &#39;Website News - &#39;.$newstitle;}else{page_description();}?>" />

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


Thanks,

malt
Logged

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Code: unique news post meta data
« Reply #1 on: June 10, 2010, 12:16:16 PM »
Have you tried this solution: http://WebsiteBaker.at/wb/module/simple-pagehead.html

cheers

Klaus
Logged

malt

  • Guest
Re: Code: unique news post meta data
« Reply #2 on: June 10, 2010, 02:54:50 PM »
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
Logged

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Code: unique news post meta data
« Reply #3 on: June 11, 2010, 09:54:59 PM »
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
Logged
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Code: unique news post meta data
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2