Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 10:02:13 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
149631 Posts in 21098 Topics by 7537 Members
Latest Member: lotte2
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Adding post titles from news mod to increase search engine stats  (Read 2068 times)
hudge

Offline Offline

Posts: 174


WWW
« on: January 04, 2007, 05:10:28 AM »

Add this at top of your index.php file in your template
Code:
<?php
$query_post 
$database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '".$post_id."'");
   if(
$query_post->numRows() > 0) {
       
$post $query_post->fetchRow();
       }
$post_title=$post['title'].' ';
?>

Add this at top of your index.php file in your head tags of your template
Code:
<title><?php page_title(); if ($post_title != ' ') { echo ' - '; } echo $post_title?></title>
Logged

: Member of the Baker's Dozen :
Baking at 350˚ for 2 hours now...
tomhung

Offline Offline

Posts: 353


« Reply #1 on: January 05, 2007, 12:30:43 AM »

nice i'll give it a try tomorrow!

beer thirty now!

Greg
Logged
AzAkers

Offline Offline

Posts: 40


WWW
« Reply #2 on: July 11, 2007, 08: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:

<title><?php if ($post_title != ' ') echo $post_titlepage_title('','[PAGE_TITLE]'); ?></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:

<title><?php if ($post_title != ' ') echo $post_titlepage_title('[PAGE_TITLE]','[WEBSITE_TITLE]'); ?></title>


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

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





and then put this in the meta content..
Code:

<meta name="description" content="<?php if ($post_description != ' ') echo $post_description; { echo '  '; } 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  cheesy

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, 08:44:45 PM by AzAkers » Logged

Contributor?  THANKS!!

WB Sites:
AZ Ladies Ministries
Logo Design in progress
abidan

Offline Offline

Posts: 102


« Reply #3 on: April 16, 2009, 12:26:16 PM »

Great tip, this is just what i needed thanks mucjly Smiley
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!