Jump to content

[SOLVED] Adding "page 2" in meta description ?


Mister Denial

Recommended Posts

Hi folks,

 

there is a fix by Presto-Changeo out to fix the duplicate meta title issue by adding a number for the titel for subsequent category pages. Is it possible to extend that to the meta description?

 

Like having "blah blah blah" as description on page 1, and "blah blah blah - page 2" for the next page, and so on?

 

I currently am facing the issue that Google ignores the dissallow: p= instruction from robots.txt and I have a load of duplicate warnings I can't get rid of.

 

Help would be much appreciated.

 

Dan

Edited by Mister Denial (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi, I tried to find a quick solution to the problem.

 

add this function to Page class.

 

 

public function custom_page_number()

{

$page_number = substr($_SERVER['REQUEST_URI'],-2);

$page_number = trim($page_number,"=");

$page_number = preg_replace('#[^0-9]#','',strip_tags($page_number));

$page_number = trim($page_number);

if(strlen($page_number) > 0) return "results ".$page_number;

else return $page_number;

}

 

it takes the last 2 characters from the url where it says ?p=2 (for page 2), and cleans the "=". Then if you are on page 1, returns empty string, if you are in page > 1, it returns "results 2,3...".

 

You can call this function everywhere, like Page::custom_page_number() and you will avoid duplicate meta description or title, etc..

 

ex: in header.tpl in your theme folder, add the following code

<meta name="description" content="{$meta_description|escape:html:'UTF-8'} {Page::custom_page_number()|escape:html:'UTF-8'}" />

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 5 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...