The Customizr WordPress theme comes with default texts for navigation at the bottom of single posts and on post lists pages.
There are some cases where you might need to change those texts, for example if you use custom posts types.
You easily change these without modifying the core code, like often in WordPress, with the help of filters!
Where to copy/paste this code ? The following code has to be pasted in your functions.php file. I strongly recommend that you create a child theme. Download a start-up child theme here.
Everything you need to know about child theme with Customizr here.
Changing the single post navigation texts
Single post navigation title
add_filter( 'tc_singular_nav_title', 'my_nav_title' ); function my_nav_title() { return 'My navigation title'; //or to make it translatable // return __('My navigation title' , 'your_translation_domain'); }
If you need to change this nav title only for a particular post type, then use the following code with your custom post type name
add_filter( 'tc_singular_nav_title', 'my_custom_post_type_nav_title' ); function my_custom_post_type_nav_title($default) { if ( 'my_custom_post_type' == get_post_type() ) return 'My custom post type navigation title'; //return default text in the other cases return $default; }
Single post navigation button’s text (left and right arrow)
In this case, we need to filter two values : previous and next button’s text.
We can do that with the same callback function using a switch statement on the current filter’s value .
add_filter( 'tc_singular_nav_next_text' , 'my_nav_buttons_text' ); add_filter( 'tc_singular_nav_previous_text' , 'my_nav_buttons_text' ); function my_nav_buttons_text() { switch ( current_filter() ) { case 'tc_singular_nav_previous_text': return 'previous post ←'; // <= your custom text here case 'tc_singular_nav_next_text': return '→ next post'; // <= your custom text here } }
Changing the post list navigation texts
You can also use the post type conditional statement for the post list.
Post list navigation title
This time, we use the ‘tc_list_nav_title’ filter
add_filter( 'tc_list_nav_title', 'my_post_list_nav_title' ); function my_post_list_nav_title() { return 'My post list navigation title'; }
Post list navigation button’s text
Same as before, we use one single callback function to filter both values :
add_filter( 'tc_list_nav_next_text' , 'my_list_nav_buttons_text'); add_filter( 'tc_list_nav_previous_text' , 'my_list_nav_buttons_text'); function my_list_nav_buttons_text() { switch ( current_filter() ) { case 'tc_list_nav_next_text': $text = '<span class="meta-nav">←</span> old posts'; break; case 'tc_list_nav_previous_text': $text = 'new posts <span class="meta-nav">→</span>'; break; } return $text; }
29 thoughts on “Changing the post navigation’s texts”
hi Nicolas! Awesome theme – best.wordpress.theme.ever!! Question: is there a way to rename the front page (posts page) without editing the code? A way to do this in the dashboard? Right now it’s “Home” but I would like to edit it to “Home – Today’s News” Thanks and keep up the good work!! Charlotte
Thanks @charlottebatson.
The developer team handles support for Customizr at https://wordpress.org/support/theme/customizr and for Customizr-Pro at http://presscustomizr.com/support/. Post your query there with a link to your site.
Hi James,
Do check this article.
Please Mr. Nicholas, how do i make a custom single post navigation. My post is too long i will like to give a cool pagination for it. I’ve been ‘googling’ for weeks now, but no success.
I thoght I’d share this as it took me some time to figure it out, with the snippet in the original post being not up-to-date. I’m a newbie, and do realize people here could be discussing alot more complicated issues, but it might save someone else the time of searching!
I used this snippet to change the post list navigation labels from “Older Posts” and “Newer Posts”
Thanks for sharing this code Sarah !
This will surely help people 🙂
I couldnt make it work, I dont know what I did wrong
Thx for Customizr!
But Changing Post list navigation button’s text (4 snippet) does not work correctly. It changes Single post navigation button’s text. And on my home page there is nothing changed. But I want change exactly my home page – with Singles posts everything is ok!
1 and 3 snippets works very good
Hi Serg,
this snippet works for your request, but only for the home page!
if you want, you can remove the conditional if/else statement and just leave the
return 'your text'
Hope it helps
Thanks Giorgio. Everything is great!
Just sharing a variation of the above snippets.
I needed to change the navigation text for a custom post type page to “<< Older Projects" link.
but I needed to keep the default Customizr text on the blog page “<< Older Posts" link.
This is my solution, raw! so any contribution to make it better is more than welcome:
I have tested this snippet on localhost with Customizr 3.2.2 and it works well!
Thanks for sharing Giorgio. When will you post another beautiful website in the showcase? 🙂 Can’t wait to see that!
hey Nicolas,
quick dumb question about my above snippet with the conditionals:
since we have only 2 hooks to navigate between lists of posts (tc_list_nav_next_text & tc_list_nav_previous_text) is there a way to add a second conditional, let’s say for instance I have a different post list in a custom page template?
something like this, but it does not work
I tried here, but no luck:
Second Blog list
While CPT list and Main Blog list are working fine 😉
thanks in advance
Hi Giorgio, the thing is that
is matched, ’cause that page is not the home page, and then ` ‘< EARLIER PUBLICATIONS'; ` is returned. You might want to do something like this:
hope this helps.
Thanks Rocco,
it is not working your snippet, but I’m bit confused by its structure: 2 returns like that are kind of overriding each other no?!
I think I’ll have to try on a fresh installation because it could be that the problem with the
is related to my custom page that has a custom loop with only 1 category to show:
This is giving me also problems in showing meta-tags on this page when only 1 category is selected… I’ll move the topic on the forum bec I’m mixing issues here.
Hi Giorgio, ok post it in the wp support forum.
And there tell me what do you mean with doesn’t work, what kind of problem you get?
And don’t get the “2 returns like that are kind of overriding each other no?” .. I can say, as a general answer, that if you use a return in an if – else statement, then the else is superfluous, ’cause the return stops the execution and .. as the word suggests, the control returns to the caller.
Hey Rocco,
I think we are just having a bit of a moment in understanding each other about your suggested snippet and my doubt:
that’s what I was try to say with my notes beside the inner returns.
BTW I’ve tried any kind of conditional allowed by wordpress, the only conditional that works are:
is_home
! is_home
and the code that Nicholas gave me for the CPT.
Moving to the Forum in regard of the Page Template not showing entry-meta when listing only a single category [it looks like a regression, bec it works fine on Customizr 3.1.24].
About my code.. it means (in pseudo-code)
if `is not home` and `is template ‘celb-page.php’` return `'< different post type left'`
else if `is not home` and `is not template 'celb-page.php'` return `'< EARLIER PUBLICATIONS'`
else (all other cases) return `'< OLDER POSTS'`
Hi Giorgio, again…
for the issue with the metas in your page template with CPT, put this code (where you define the query maybe, or earlier):
`add_filter(‘tc_show_post_metas’, ‘__return_true’);`
hope this helps.
You are just great!
Too bad, I just finished to write a long post on the forum!
add_filter(‘tc_show_post_metas’, ‘__return_true’);
did the trick!
Maaany thanks
Thanks Nicolas for your response
but it does not work even now.
the text changes but the links to the articles you will lose.
🙁
Fixed in the snippet above! Link is working now 🙂
I do not understand. still does not work.
the snippet changes the text but the link is disabled.
This makes it impossible to navigate the post.
excuse my english, I’m Italian.
thanks for the effort
Hi Anna, English is not my native language as well. Your english is fine!
I don’t understand either, this snippet works fine for me: I can click on the links and navigate through the posts.
You might maybe check that you have pasted the entire code…
Hope this helps!
thanks Nicolas
the last snippet posted works great.
🙂
Gambling still a demand. There is a way to limit the navigation to only post in the single category.
in any case I am very happy with the work done, I agiunto many of your snippet and now my site is finished and I find it wonderful. thank you thank you
Hi Anna, I am glad it helped.
Here’s a snippet to restrict the post navigation to the same category in WordPress.
Live long and prosper with Customizr!
Hello.
I did several tests, but I can not figure out how I can replace the “title of the articles” with “next / previous”.
You can make this change?
can you help me?
thank you very much
anna
Hi Anna,
There was an error in the above snippet.
The correct code to change the button text of the single post navigation is :
Thanks for your feedback and enjoy the theme,
Nicolas.
Hi Nicolas,
I was wondering is it possible to alter the post navigation feature in posts to navigate within categories, rather than all posts on the website in date order (which seems to be the default WordPress behaviour)
http://www.busheymeads.org.uk/blog/category/newsletter-articles/ (for example when you click on any post within this category, by default the navigation links seem to navigate to all posts in all categories in date order)
Can the post navigation links be easily changed?
Thanks,