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.8 is now available!


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.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Adding post titles from news mod to increase search engine stats
  • Print
Pages: [1]   Go Down

Author Topic: Adding post titles from news mod to increase search engine stats  (Read 8206 times)

hudge

  • Guest
Adding post titles from news mod to increase search engine stats
« 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>
Logged

tomhung

  • Guest
Re: Adding post titles from news mod to increase search engine stats
« Reply #1 on: January 05, 2007, 12:30:43 AM »
nice i'll give it a try tomorrow!

beer thirty now!

Greg
Logged

AzAkers

  • Guest
Re: Adding post titles from news mod to increase search engine stats
« Reply #2 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

Click one of the articles there - I linked to the section rather than the individual article since the URL shouldn't change over time
« Last Edit: July 11, 2007, 09:44:45 PM by AzAkers »
Logged

abidan

  • Guest
Re: Adding post titles from news mod to increase search engine stats
« Reply #3 on: April 16, 2009, 01:26:16 PM »
Great tip, this is just what i needed thanks mucjly :)
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Adding post titles from news mod to increase search engine stats
 

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