Changing the post navigation’s texts


Note :This snippet works only with the Classical style option. The Classical style option can be enabled in Appearance > Customize > Advanced > Theme Style. More about the theme style option here


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

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

 

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 .

 

 

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

 

Post list navigation button’s text

Same as before, we use one single callback function to filter both values :

 


Related Snippets you may also like


29 thoughts on “Changing the post navigation’s texts

  • charlottebatson

    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

  • James

    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.

  • Sarah

    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”

    • Kiki

      I couldnt make it work, I dont know what I did wrong

  • Serg

    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

    • Giorgio25b

      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

  • Giorgio25b

    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!

      • Giorgio25b

        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

        • Rocco Aliberti

          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.

          • Giorgio25b

            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.

            • Rocco Aliberti

              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.

            • Giorgio25b

              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].

            • Rocco Aliberti

              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'

            • Rocco Aliberti

              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.

            • Giorgio25b

              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

  • Anna

    Thanks Nicolas for your response
    but it does not work even now.
    the text changes but the links to the articles you will lose.
    🙁

      • Anna

        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

        • Nicolas Post author

          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!

  • Anna

    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

    • Nicolas Post author

      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.

  • Jon

    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,

Comments are closed.