Custom text for 'Older' 'Newer' buttons?

Is it possible to change the text in these two buttons? For example for another language purposes.


Hi @teodordobrzycki! This can be done by adding bit of Custom JavaScript in your blog’s Customize settings. Just replace the text at the end with your preferred wording and you should be good to go.

/* Older Text */
document.getElementById('paging').getElementsByTagName('a')[0].innerText = '⇠ Older';

/* Newer Text */
document.getElementById('paging').getElementsByTagName('a')[1].innerText = 'Newer ⇢';

1 Like

Just tried, it works well on the first page and middle pages. Unfortunately on the last page it does not. Instead of displaying the “Newer text” it displays the “Older text” (on the right side).

Guess this is related to the “[1]” becoming “[0]” on the last page.

Any idea?
Thank you

Here is a trick I just found, but almost sure there exist a more efficient solution.

var url = window.location.pathname;
var page = url.substring(url.lastIndexOf('/') + 1);
var pagemax = 3; /* Define the number of pages in your blog */
if (page == pagemax) {
document.getElementById('paging').getElementsByTagName('a')[0].innerText = 'Newer ➡';
} else {
document.getElementById('paging').getElementsByTagName('a')[0].innerText = '⬅ Older';
document.getElementById('paging').getElementsByTagName('a')[1].innerText = 'Newer ➡';

Just need to replace the variable pagemax to match the number of pages in your blog.

1 Like

Yep you got it, that’s an issue with the code — a foresight on my part so my apologies there.

Your trick is a great solution around this though. I am thinking there might be a way to programmatically figure out what your max page is rather than having it hardcoded. Will have to look into that…

Thank you :slight_smile:

This may help: I noticed that typing a great number into the url always returns the latest page number. Keeping pagemax as the # of page on the blog, we have:

that returns :
instead of something like “Sorry, this page does not exist.

which let me think that there may be something already existing to define the maximum number of page of each blog…

Thank you again !