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.
This is the easiest way to remove page/1/ from the link.
Thank you for this tutorial.
You are most welcome.
Thank you that fixed my problem as well
You are welcome.
Nice one!
Thank you so much for this easy fix!
You are welcome.
Thanks a lot !
Thank you very much! I searched for this solution in my language, but found nothing. I Googled it in English and the first link is yours.
A simple and effective solution to the problem.
You are welcome.