You are here:  » Metadescription and keywords on


Metadescription and keywords on

Submitted by wesse249 on Sat, 2015-03-21 19:53 in

Hello,

I'd like to have also on my merchant, category and brand pages meta descriptions.

So for example by brand:

<title>Canvas Cars Racing Aanbieding example.com</title>
<meta name='description' content='on this page you find all apple product' />
<meta name='keywords' content='apple' />

And above the same for merchant and category.

Thank you

Submitted by support on Sun, 2015-03-22 11:14

Hi,

Sure - in search.php look for where the header HTML is included by this code at line 418:

  require("html/header.php");

...and REPLACE with, for example:

  if (isset($parts[1]))
  {
    $header["meta"]["description"] = "on this page you will find all ".$parts[1]." products";
    $header["meta"]["keywords"] = $parts[1];
  }
  require("html/header.php");

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Sun, 2015-03-22 18:32

Hi David,

I did not leave the chance to insert this code :-)

Look what occured to me.
At meta description ".$parts[1]." position appears the whole category path. Is it possible - and I believe more normal -to appear just the last subcategory. For instance at the following just "Ανδρικά Δετά"

Cheers

S

Submitted by support on Mon, 2015-03-23 08:26

Hello Steve,

In place of

$parts[1]

use:

($parts[0]=="category"?$names[count($names)-1]:$parts[1])

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Mon, 2015-03-23 09:02

Thanks a lot David!

Submitted by wesse249 on Mon, 2015-03-23 13:15

Thanks David for the great and quick support!

Is it also possible to use for category, merchant and brand to have different meta descriptions and keywords?

For example:

Category:
$header["meta"]["description"] = "on this category page you will find all ".$parts[1]." products";
$header["meta"]["keywords"] = $parts[1];

Merchant:
$header["meta"]["description"] = "on this merchant page you will find all ".$parts[1]." products";
$header["meta"]["keywords"] = $parts[1];

Brand:
$header["meta"]["description"] = "on this brand page you will find all ".$parts[1]." products";
$header["meta"]["keywords"] = $parts[1];

Thanks a lot.

Submitted by support on Mon, 2015-03-23 20:23

Sure - as an alternative replacement to the above, use the following with a switch() statement against $parts[0] (which contains "merchant", "category" or "brand") so you can customise each as required:

  if (isset($parts[1]))
  {
    switch($parts[0])
    {
      case "merchant":
        $header["meta"]["description"] = "on this merchant page you will find all ".$parts[1]." products";
        $header["meta"]["keywords"] = $parts[1];
        break;
      case "category":
        $header["meta"]["description"] = "on this category page you will find all ".$parts[1]." products";
        $header["meta"]["keywords"] = $parts[1];
        break;
      case "brand":
        $header["meta"]["description"] = "on this brand page you will find all ".$parts[1]." products";
        $header["meta"]["keywords"] = $parts[1];
        break;
    }
  }
  require("html/header.php");

Cheers,
David.
--
PriceTapestry.com

Submitted by wesse249 on Fri, 2015-05-08 18:44

Hello David,

Is it also possible to give products page his own meta description and keywords like above?

Thanks Jan Roel

Submitted by support on Sat, 2015-05-09 08:51

Hello Jan,

A meta description and keywords tag is already generated on the product pages, but this can be customised easily. In products.php look for the following code around line 71:

    $header["meta"]["description"] = translate("Price search results for")." ".$q;
    $header["meta"]["keywords"] = $q;

$q pulls in the product name, so essentially the keywords field is just the product name, and the description the translated version of "Price search results for {product name}".

For a niche site, if you wanted to create unique description / keyword values for specific products you could do this easily through a code modification at this point, with the above code as a default using something like:

    switch($product["products"][0]["name"])
    {
      case "Product 1":
        $header["meta"]["description"] = "Product 1 Meta Description";
        $header["meta"]["keywords"] = "product 1, meta, keywords";
        break;
      case "Product 2":
        $header["meta"]["description"] = "Product 2 Meta Description";
        $header["meta"]["keywords"] = "product 2, meta, keywords";
        break;
      default:
        $header["meta"]["description"] = translate("Price search results for")." ".$q;
        $header["meta"]["keywords"] = $q;
        break;
    }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Fri, 2015-06-12 16:27

Hi David,

Hope all is going well.

I have been making some mods to the meta descriptions and keywords of one of my sites and have used the above code for the merchant and brand pages which works well except that I would also like to create meta keywords (phrases) which include the brand embedded in each phrase. I can get one keyword phrase to be created but when I add more nothing else is added. I'm using the code:

        $header["meta"]["keywords"] = "Compare ".($parts[0]=="category"?$names[count($names)-1]:$parts[1])." prices"; ",discount ".($parts[0]=="category"?$names[count($names)-1]:$parts[1])." widgets";
        break;
    }

I have tried a number of variations of the above without success and wondered if you might possibly be able to tell me what it should be?

Thanks in advance.

Regards
Chris

Submitted by support on Sat, 2015-06-13 10:29

Hi Chris,

Have a go with the line;

$header["meta"]["keywords"] = "Compare ".($parts[0]=="category"?$names[count($names)-1]:$parts[1])." prices, discount ".($parts[0]=="brand"?", ".$parts[1]:"");

This ternary will give the brand name for a brand: query:

($parts[0]=="brand"?", ".$parts[1]:"")

A ternary is essentially a shorthand IF / THEN / ELSE:

(if?then:else)

...where "then" and "else" are the return values respectively...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Sun, 2015-06-14 22:12

Hi David,

Hope you have had a good weekend. Thanks for the above which works beautifully.

Best regards
Chris