Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Header configuration & styling (http://forum.bytesforall.com/forumdisplay.php?f=15)
-   -   Pls help me change this code<title><?php bloginfo('name'); ?><?php wp_title(); ?></ti (http://forum.bytesforall.com/showthread.php?t=5503)

tobywinn Jan 25, 2010 01:48 PM

Pls help me change this code<title><?php bloginfo('name'); ?><?php wp_title(); ?></ti
 
I have an eccommerce site - http://www.amberpumpkin.com - it has lots of products but they all have the same page titles.

I need to replace it with the code below - then it will take the product name and put it in the title - great for SEO.

I can't find the bit of code to change.

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

brianwp Nov 18, 2011 11:51 AM

I know this is an old thread and looks to be resolved on the OP's site but since it comes up in the search results for "bloginfo( 'name' )" and hasn't been answered and I was trying to figure out something similar with a client's site, I thought I would answer it.

Since this code involves the title tag as it is between "<title>" and "</title>" it must be the header.php file in whatever theme you're using. For our site it is like "/blog/wp-content/themes/your_theme_name/header.php".

I'm new to hacking WordPress and was trying to figure out why the title tag was duplicated and realized it's because it has both "wp_title();" and "bloginfo( 'name' );" in the <title> tag. I commented out the bloginfo( 'name' ); (like so
PHP Code:

//bloginfo( 'name' ); 

for those who aren't programmers) and now it displays properly.

It used to say
Quote:

Mountainside Medical Blog | Online Medical Supplies NewsMountainside Medical Blog | Online Medical Supplies News
and now it just says,
Quote:

Mountainside Medical Blog | Online Medical Supplies News
as you can see at www. mountainside-medical.com/blog/ at the moment.

Now, I just need to figure out how to fix the incorrect link on the category pages like this one www. mountainside-medical.com/blog/category/diabetes-supplies/ where it says
Quote:

Posted by admin">
.


All times are GMT -6. The time now is 11:02 AM.

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