Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » eCommerce & Atahualpa »

Changing product page titles - not sure how to do it.


 
Prev Previous Post   Next Post Next
  #1  
Old Jan 20, 2010, 02:59 PM
tobywinn
 
15 posts · Jun 2009
Changing product page titles - not sure how to do it.

HAPPY TO PAY DONATION IF YOU CAN HELP!

Hi

Thanks for a great theme. On my site - http://www.amberpumpkin.com I have used the wp-ecommerce plugin and all is going well - I am getting people buying!!!

It was recommended changing the header.php so the product title is the page title rather than products pages.

Please see below the instructions I am following. When I try and change what they say I cant find it.

The file to take a look at is actually in your theme's folder. Login using your ftp client to and then navigate to:
wp_content/themes/yourtheme/header.php
(where 'yourtheme' is the name of the theme that you are using).
Open this file for editing and the find the line that reads something like:
<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
We want to replace this code, primarily to help Wordpress pick up the title of your actual product for the browser title (important for SEO), rather than the default which is to simply call it 'products' or something similar.
No doubt this will eventually become part of the standard plugin at some stage – but we give full and unequivocal credit to Dave at Dew Point Product ions for this nice piece of code (you should visit the site and hook up with them for some SEO work to make sure you are ranking highly for your desired keywords!)
So – the code to replace is now found – here is the code to put there instead:

<title><?php
function oGetProductName( $meta ){
global $table_prefix;
$query = "SELECT product_id
FROM ".$table_prefix."wpsc_productmeta
WHERE meta_value = '".$meta."'";
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
$productid = $row[0];
$query = "SELECT name
FROM ".$table_prefix."product_list
WHERE id = ".$productid;
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
$productname = $row[0];
return $productname;
}
function oGetCategoryName( $nicename ){
global $table_prefix;
$query = "SELECT name
FROM ".$table_prefix."product_categories
WHERE `nice-name` = '".$nicename."'";
$result = mysql_query( $query );
$row = mysql_fetch_array( $result );
[RETURN TO CONTENTS] ©STasticDesigns.
$categoryname = $row[0];
return $categoryname;
}
if( is_page() && trim(wp_title ('',false )) == 'Products Page' ){
$pparts = explode('/', trim($_SERVER['REQUEST_URI'],'/') );
if( $pparts[2] != '' ){
echo oGetProductName( $pparts[2] );
}
else if( $pparts[1] != '' ){
echo oGetCategoryName( $pparts[1] );
}
else{
wp_title (''); echo ' at Your Site Name';
}
}
else{ if ( is_single() ){ wp_title(''); }elseif (is_404()){ echo 'Your Site Name - 404 Error';
}elseif (is_category()) { echo single_cat_title(); echo ' at Your Site Name'; }elseif
(is_page()) {
wp_title (''); echo ' at Welsh Farm Organics'; }else{ echo 'Your Site Name'; }
}
?></title>
Essentially what this does is grab the title of your product and use that by being clever with the SQL that is being used by the WP-Ecommerce plugin.

The result is much nicer URLs which are far more likely to help your SEO efforts.
Now go and check your site. You should see absolutely no differences to your existing URLs at all as this only affects the WP-Ecommerce URLs.


Thanks

Toby

Last edited by tobywinn; Jan 25, 2010 at 01:48 PM. Reason: need a reply so paying donation!
 

Bookmarks

Tags
e-commerce, header php, page titles, seo, wp-ecommerce

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ThemeFrame as a Service instead of a Product? Flynn ThemeFrame Presales 7 Nov 21, 2009 05:22 PM
Changing Color and Font for Post titles daisy24 Atahualpa 3 Wordpress theme 2 Nov 17, 2009 01:40 PM
Changing Post and Page titles to h1 tags RickHart Atahualpa 3 Wordpress theme 2 Sep 17, 2009 06:51 PM
RSS Feeds: Changing Titles and Descriptions anonuser RSS, Feeds & Subscribing 3 Aug 23, 2009 09:03 PM
Changing Font in Pg Menu & Pg Titles ofpeb Page & Category Menu Bars 1 Apr 23, 2009 09:30 PM


All times are GMT -6. The time now is 09:30 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.