Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   eCommerce & Atahualpa (http://forum.bytesforall.com/forumdisplay.php?f=31)
-   -   Changing product page titles - not sure how to do it. (http://forum.bytesforall.com/showthread.php?t=5411)

tobywinn Jan 20, 2010 02:59 PM

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 :)

Gavnav Feb 2, 2010 07:39 AM

Dear tobywinn

I seem to be in the same boat as you.

I have searched the web on how to make WP E-commerce SEO friendly and also came across the two post (one from dewpointproductions and one other). I did not see you post when I posted the same question....

Anyway, I am a newbie and cannot find the relevant Header.php file section.

As it appears to be a theme issue and not a WP e-commerce problem (or vice versa - as WP e-commerce uses H1 tags instead of H2 or something).

I have posted my post here: http://forum.bytesforall.com/showthread.php?t=5640

I have had lots of views, no replies.

Let's hold thumbs for an answer and solution.

Regards
Gavin

juggledad Feb 2, 2010 12:43 PM

the <title> code is in bfa_meta_tags.php

tobywinn Feb 4, 2010 03:42 PM

Appreciate your help but I changed it and nothing happened.

Very happy to make a donation if you can help make it work.

Regards


Toby

juggledad Feb 5, 2010 03:20 PM

What exactly did you change?

tobywinn Feb 9, 2010 03:02 PM

Sorry for delay - I changed:

<title><?php wp_title('&laquo;', true, 'right'); ?><?php bloginfo('name'); ?></title>

For the code in the thread above.


Thanks


All times are GMT -6. The time now is 03:00 AM.

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