Does your site run on Perch CMS? Hire me to help. Perch CMS Development

Page numbers in page titles and meta descriptions

Posted on by Clive Walker in Perch Code Snippet

I wrote this post a while back. The content can still be relevant but the information I've linked to may not be available.

I want to output page numbers (and a separator character) in the page code for paginated pages on this site. Mostly, I want to do this so that the pages have different page titles and meta descriptions. And so that I don't get page duplication or same page title/description warnings from Google in my Search Console account.

I use this PHP snippet:

<?php if(isset($_GET['page'])) echo " | page ". $_GET['page'];  //outputs page number ?>

This checks that the page number value is in the query string and outputs it and a separator " | " wherever I want.

If using Perch CMS, you can echo the page number like this:

<?php echo intval(perch_get('page')); ?>

... although this will output "0" on the very first page as well. You may not want this so you will need to check for that and amend the code accordingly.

Does your site run on Perch CMS? Hire me to help. Perch CMS Development

Comments are OFF for this post.

© 2024 Clive Walker