You are here:  » Unique Meta Title and Description for Categories


Unique Meta Title and Description for Categories

Submitted by DubaiCrazy on Tue, 2017-04-04 13:00 in

Is there a way to get unique Meta Titles and Meta Descriptions for Category pages?

Thanks, Chris

Submitted by support on Wed, 2017-04-05 08:22

Hi Chris,

You could use a method almost identical to the Unique category description mod - create a folder "categorymeta/" containing .php files exactly matching the category name e.g.

categorymeta/Category One.php
categorymeta/Category Two.php

...containing as follows:

<?php
  $header
["meta"]["description"] = "Category meta description";
  
$header["meta"]["keywords"] = "category, meta, keywords";
?>

Then in search.php look for the following code at line 350:

        case "category":

...and REPLACE with:

        case "category":
          if ($page==1)
          {
            $filename = "categorymeta/".$parts[1].".php";
            if (file_exists($filename))
            {
              require($filename);
            }
          }

If you'd prefer to have the description and keywords on every page, perhaps resolved with de-duplication as per the title just let me know...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by DubaiCrazy on Thu, 2017-04-06 09:13

Thanks David - I was hoping this would change the tag but that has stayed the same - is there a way of using this method to update the tag for the page to what I define in the categorymeta folder?

Thanks, Chris

Submitted by support on Thu, 2017-04-06 09:44

Hi Chris,

Did you mean to set a custom title per category also? That's no problem, firstly with the title added to the included file e.g.

<?php
  $header
["meta"]["description"] = "Category meta description";
  
$header["meta"]["keywords"] = "category, meta, keywords";
  
$header["title"] = "Category Title";
?>

And then in search.php look for the following code at line 503:

    $header["title"] = $q;

...and REPLACE with:

    if (!isset($header["title"])) $header["title"] = $q;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com