You are here:  » Titles and description in Google


Titles and description in Google

Submitted by Fuzzy on Tue, 2012-04-24 01:03 in

Website: {link saved}
Google Search titles: {link saved}

I am a bit at a loss why my title descriptions in google are showing my recent posts for every Price Tapestry item.(see above google results) How does pt generate the meta description for each product when placed in wordpress or am I doing something completely wrong :)?

I currently have header exclusivity set to enabled.

Thanks again.

Submitted by support on Tue, 2012-04-24 08:49

Hi Fuzzy,

Everything looks fine on the page - canonical is correct and the meta description is the plugin generated "Price search results for [product name]", however I do see that your latest blog post titles are what is being used in this case - which do appear on the page and ultimately there is no way to actually control the description used by search engines.

However, if you wanted to pull the actual product description into the meta description tag you could do this as follows: In pto.php look for the following code at line 209:

      $description = $pto_html_product_description;

...and REPLACE with:

      global $wpdb;
      global $pto_config_databaseTablePrefix;
      $description = $pto_html_product_description;
      $productDescription = "";
      $sql = "SELECT description FROM `".$pto_config_databaseTablePrefix."products` WHERE name = '".$wpdb->escape($pto_productName)."' AND description <> '' LIMIT 1";
      if ($wpdb->query($sql))
      {
        $productDescription = $wpdb->last_result[0]->description;
      }
      $description = str_replace("%DESCRIPTION%",$productDescription,$description);

With that in place, you can now use the %DESCRIPTION% placeholder within the Meta Description template (wp-admin > Settings > PriceTapestry.org)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Fuzzy on Tue, 2012-04-24 13:50

Thanks David!

Submitted by IG on Fri, 2012-05-04 20:43

When I replace the above code as suggested and use %DESCRIPTION% placeholder within the Meta Description template, my website shows the following error message:

Fatal error: Call to a member function escape() on a non-object in /var/www/vhosts/shoppingcity.ch/httpdocs/wp-content/plugins/pto/pto.php on line 211

Submitted by support on Sat, 2012-05-05 10:16

Sorry Ivo,

$wpdb needs to be declared global, I've corrected this in the code above by adding the following line to the top of the modification:

      global $wpdb;

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Sun, 2012-05-06 08:03

Hi David

When I use the modified code, the error is gone, but the source code does not show any description at all.

Submitted by support on Mon, 2012-05-07 10:42

Ah sorry about that - the following global is also required (added above)

      global $pto_config_databaseTablePrefix;

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Mon, 2012-05-07 14:28

Hi David

Works perfect now - thanks. Is it possible to limit the meta description to the first 165 characters of the product description?

Cheers, Ivo

Submitted by support on Tue, 2012-05-08 10:01

Hello Ivo,

Sure - on the last line of the modification, in place of:

$description = str_replace("%DESCRIPTION%",$productDescription,$description);

...use:

$description = str_replace("%DESCRIPTION%",pto_common_substr($productDescription,165),$description);

That will break cleanly on the first space after 165 characters...

Cheers,
David.
--
PriceTapestry.com

Submitted by IG on Tue, 2012-05-08 11:17

You are a star!

Submitted by george-p on Sat, 2013-11-09 22:57

Hello David

i tried the same code but the description is emply

also at Price Tapestry plugin page there is not setting to set header exclusivity and also i dont use any seo plugin

Submitted by support on Sun, 2013-11-10 10:47

Hello George,

The latest version no longer has the header exclusivity setting since additional hooks are used to enable compatibility with SEO plugins so this is no longer required.

To add support for %DESCRIPTION% in your Product / Meta Description template, in pto.php look for the following code at line 347:

$description = str_replace("%PRODUCT_NAME%",htmlspecialchars($pto_productResults[0]->name),$description);

...and REPLACE with:

$description = str_replace("%PRODUCT_NAME%",htmlspecialchars($pto_productResults[0]->name),$description);
$description = str_replace("%DESCRIPTION%",htmlspecialchars($pto_productResults[0]->description),$description);

Cheers,
David.
--
PriceTapestry.com

Submitted by george-p on Sun, 2013-11-10 15:04

thanks David

works great!

Submitted by Perce2 on Sun, 2016-10-30 10:58

Using your code;

$description = str_replace("%PRODUCT_NAME%",htmlspecialchars($pto_productResults[0]->name),$description);
$description = str_replace("%DESCRIPTION%",htmlspecialchars($pto_productResults[0]->description),$description);

Is it still possible to limit the meta description to the first 165 characters of the product description again?

Submitted by support on Wed, 2016-11-02 09:15

Hi,

Sorry for the disappearing posts I was having forum database issues yesterday - please try:

$description = str_replace("%PRODUCT_NAME%",htmlspecialchars($pto_productResults[0]->name),$description);
$description = str_replace("%DESCRIPTION%",htmlspecialchars($pto_productResults[0]->description),$description);
$description = pto_common_substr($description,165);

Cheers,
David.
--
PriceTapestry.com

Submitted by Perce2 on Wed, 2016-11-02 09:34

That sorted it!

Many thanks David