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; }