Hi David
Where can I go to update the Title, Meta Keyword and Meta description for Search Result Page?
Currently title of my search result page is displayed as below and there is no meta keyword & description showing in html source code of the page:
ProductName | priceAsc | Shopping | SiteURL
I can update similar settings for product page under Setting>pricetapestry.org>Product
but I don't where are the these settings for search result page.
I will appreciate your help.
Regards
Hassan
Thanks Meta Keywords and description are working great.
How can update the Title text? adding something before/after search query.
currently it is:
searchQuery | Shopping | SiteURL
Regards
Hassan
Hi Hassan,
The search results page title is set by the following code at line 431 of pto.php:
$title = htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"));
...REPLACE this with:
$title = "Before Text ".htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"))." After Text";
...as required to create the title you want...
Cheers,
David.
--
PriceTapestry.com
Hello David
I have tried %DESCRIPTION% to set it in meta description but didn't work, how can you set this.
And the line value= i have changed to content=
Thx
Henk
Hello Henk,
First look for the following code beginning at line 389 of pto.php
$sql = "SELECT name FROM `".$pto_config_databaseTablePrefix."products` WHERE normalised_name='".$wpdb->escape($pto_product)."' LIMIT 1";
if ($wpdb->query($sql))
{
$pto_productName = $wpdb->last_result[0]->name;
}
....and REPLACE with:
$sql = "SELECT name,description FROM `".$pto_config_databaseTablePrefix."products` WHERE normalised_name='".$wpdb->escape($pto_product)."' LIMIT 1";
if ($wpdb->query($sql))
{
$pto_productName = $wpdb->last_result[0]->name;
global $pto_productDescription;
$pto_productDescription = $wpdb->last_result[0]->description;
}
And then just above the point you have already identified, at line 213:
$description = str_replace("%PRODUCT_NAME%",htmlentities($pto_productName,ENT_QUOTES,get_settings("blog_charset")),$description);
...REPLACE with:
$description = str_replace("%PRODUCT_NAME%",htmlentities($pto_productName,ENT_QUOTES,get_settings("blog_charset")),$description);
global $pto_productDescription;
$description = str_replace("%DESCRIPTION%",htmlentities($pto_productDescription,ENT_QUOTES,get_settings("blog_charset")),$description);
(I know you're using a modified beta version so if you're not sure email me your latest version and I'll make the changes for you...)
Cheers,
David.
--
PriceTapestry.com
Super Thx
2 questions for today:)
1) is it possible to strip this description
2) in the title of the page there is now merchant: can it be winkel:
Henk
Hi Henk,
To strip HTML from the description use:
$description = str_replace("%DESCRIPTION%",htmlentities(strip_tags($pto_productDescription),ENT_QUOTES,get_settings("blog_charset")),$description);
The page title for search results (which generate the merchant index) is set by the following code at line 431 of pto.php:
$title = htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"));
...so to change out merchant: for winkel: REPLACE with:
$title = htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"));
$title = str_replace("merchant:","winkel:",$title);
Cheers,
David.
--
PriceTapestry.com
Hello David
i used this code to add description to category,merchant,brand,search.. and works fine
global $pto_q;
if ($pto_q)
{
print "<meta name='description' value='Search results for ".htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"))."' />\n";
}
else switch($pto_module)
how i can make it to have different description for category/merchant/brand/search ?
also i used successful this code from here http://www.pricetapestry.org/node/374 to have different meta titles
$title_pto_q = str_replace(array("category"),"Κατηγορία ",$pto_q);
$title_pto_q = str_replace(array("merchant"),"Κατάστημα ",$title_pto_q);
$title_pto_q = str_replace(array("brand"),"Μάρκα ",$title_pto_q);
$title_pto_q = str_replace(array(":"),"",$title_pto_q);
$title = htmlentities($title_pto_q,ENT_QUOTES,get_settings("blog_charset"));
how i can also make it for each of this pages to print h1 title
thanks
Hello George,
Use you split $pto_q by ":" and then check the first part for merchant, category or brand, and then have a different description for each, optionally using the second part as well if required. Have a go with:
global $pto_q;
if ($pto_q)
{
$parts = explode(":",$pto_q);
switch($parts[0])
{
case "merchant":
print "<meta name='description' value='Merchant search results for ".htmlentities($parts[1],ENT_QUOTES,get_settings("blog_charset"))."' />\n";
break;
case "category":
print "<meta name='description' value='Category search results for ".htmlentities($parts[1],ENT_QUOTES,get_settings("blog_charset"))."' />\n";
break;
case "brand":
print "<meta name='description' value='Brand search results for ".htmlentities($parts[1],ENT_QUOTES,get_settings("blog_charset"))."' />\n";
break;
default:
print "<meta name='description' value='Search results for ".htmlentities($parts[1],ENT_QUOTES,get_settings("blog_charset"))."' />\n";
break;
}
}
else switch($pto_module)
To output $title_pto_q in h1 tags, make the variable global by adding global $title_pto_q; as follows:
global $title_pto_q;
$title_pto_q = str_replace(array("category"),"Κατηγορία ",$pto_q);
$title_pto_q = str_replace(array("merchant"),"Κατάστημα ",$title_pto_q);
$title_pto_q = str_replace(array("brand"),"Μάρκα ",$title_pto_q);
$title_pto_q = str_replace(array(":"),"",$title_pto_q);
$title = htmlentities($title_pto_q,ENT_QUOTES,get_settings("blog_charset"));
Then in pto_search.php look for the following code at line 483 at the end of the pto_search_banner function:
return $html;
...and REPLACE with:
global $title_pto_q;
$html = str_replace("%TITLE_PTO_Q%",$title_pto_q,$html);
return $html;
And then finally, edit your Search / Banner template, adding:
<h1>%TITLE_PTO_Q%</h1>
...as required.
Cheers,
David.
--
PriceTapestry.com
Hi Hassan,
Sure - meta tags are generated within pto.php as part of the pto_head() function. Within that file, look for the following code at line 184:
switch($pto_module)
...and REPLACE with:
global $pto_q;
if ($pto_q)
{
print "<meta name='keywords' value='".htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"))."' />\n";
print "<meta name='description' value='Search results for ".htmlentities($pto_q,ENT_QUOTES,get_settings("blog_charset"))."' />\n";
}
else switch($pto_module)
The above code will simply output the query itself as the meta keywords and "Search results for [keywords]" as the meta description; but of course anything you want can be included before / after the dynamic text - notice how the code print the meta tag directly breaking out of the string to include the value of $pto_q but either side of that you can insert anything you want within the value='...' settings - let me know if you're not sure - in which case if you could post an example of what you want to display as meta keywords / descriptions for a given query I can work the code out for you from that...
Cheers,
David.
--
PriceTapestry.com
Please note limited support availability 18-25 July 2012
http://www.pricetapestry.com/node/4689