WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: hudge on January 04, 2007, 05:10:28 AM

Title: Adding post titles from news mod to increase search engine stats
Post by: hudge on January 04, 2007, 05:10:28 AM
Add this at top of your index.php file in your template
Code: [Select]
<?php
$query_post 
$database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = &#39;".$post_id."&#39;");
   if(
$query_post->numRows() > 0) {
       
$post $query_post->fetchRow();
       }
$post_title=$post[&#39;title&#39;].&#39; &#39;;
?>

Add this at top of your index.php file in your head tags of your template
Code: [Select]
<title><?php page_title(); if ($post_title != &#39; &#39;) { echo &#39; - &#39;; } echo $post_title; ?></title>
Title: Re: Adding post titles from news mod to increase search engine stats
Post by: tomhung on January 05, 2007, 12:30:43 AM
nice i'll give it a try tomorrow!

beer thirty now!

Greg
Title: Re: Adding post titles from news mod to increase search engine stats
Post by: AzAkers on July 11, 2007, 09:19:59 PM
This works fantastic!

I altered it a bit and used the modified version to pull in the 'short content' into the meta description too.

For the title I reversed the order of the elements - so that the article title appears first, and the website name does not appear in the titles...
Code: [Select]

<title><?php if ($post_title != &#39; &#39;) echo $post_title; page_title(&#39;&#39;,&#39;[PAGE_TITLE]&#39;); ?></title>



NOTE: This effects titles site wide - if you want your website name to remain in your title, but at the end I think you can use something like...
Code: [Select]

<title><?php if ($post_title != &#39; &#39;) echo $post_title; page_title(&#39;[PAGE_TITLE]&#39;,&#39;[WEBSITE_TITLE]&#39;); ?></title>


For the unique description hack I added this initial code (before the doctype - same as the title hack)...
Code: [Select]

<?php
$query_post 
$database->query("SELECT content_short FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = &#39;".$post_id."&#39;");
   if(
$query_post->numRows() > 0) {
       
$post $query_post->fetchRow();
       }
$post_description=$post[&#39;content_short&#39;].&#39; &#39;;
?>





and then put this in the meta content..
Code: [Select]

<meta name="description" content="<?php if ($post_description != &#39; &#39;) echo $post_description; { echo &#39;  &#39;; } page_description(); ?>" />



I'm no programer so there is probably a more effecient way to accomplish this but I'm tickled pink with myself for managing this much  :lol:

Here is a link to a working sample:
Christian Articles (http://www.arizonaladiesministries.com/pages/christian-articles.php)

Click one of the articles there - I linked to the section rather than the individual article since the URL shouldn't change over time
Title: Re: Adding post titles from news mod to increase search engine stats
Post by: abidan on April 16, 2009, 01:26:16 PM
Great tip, this is just what i needed thanks mucjly :)