Home » Tutorial » How to Remove page/1/ from WordPress Pagination

How to Remove page/1/ from WordPress Pagination

WordPress Pagination

Pagination is the process of dividing a document into discrete pages. It’s very useful when you have a lot of content.

If you are using paginate_links on your website to create pagination, you may face the following problem:

When you are on page 2 or on any other page and you want to return to the first page, you may notice that the url for the first page is https://www.url.com/page/1

This is really annoying. Because it will create a redirection. Therefore, you just want it to be https://www.url.com

You want to remove /page/1 from the URL of the first page. Right?

Don’t worry. There is an easy solution.

WordPress pagination first page URL, change link for page 1

Paste following code before your paginate_links or on functions.php

add_filter( 'paginate_links', function($link){
if(is_paged()){$link= str_replace('page/1/', '', $link);}
return $link;
} );

Comment below to let me know if it works or not.

Tutorial: How to Paginate Taxonomy Terms with Posts Number

Read more from Tutorial

Written by:

Morshed Alam
A teacher by profession, a traveler by passion and a netizen by choice.

Have you written on ThoughtMight?Write Today



Leave a Comment

Your email address will not be published. Required fields are marked *