<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 );
$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 Your Site Name’; }else{ echo ‘Your Site Name’; }
}
?></title>