Support » Plugin: WP Post Nav » Nav button text change

  • Resolved andrasch

    (@andrasch)


    Hello,

    I really like this plugin but I am wondering if it is possible to change the text? My blog is in a different language therefore it would be awesome if I could change the text on ‘Next Post’ and ‘Previous Post’
    I am a beginner so I am not familiar with coding.
    Please advise
    Thanks a lot
    Andras

    • This topic was modified 1 year, 2 months ago by andrasch.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Jo4nny8

    (@jo4nny8)

    @andrasch
    There is a built in filter for exactly this.

    Essentially you are taking whichever phrase you wish to translate and then turn it into something else.

    Some examples are included in the examples.txt file in the plugin folder, however ive copied it below.

    
    /Translations without a plugin
    //wrap in a conditional if required
    $type = get_post_type();
    if ($type = 'post') {
      function wp_post_nav_translate( $translated_text, $text, $domain ) {
        switch ( $translated_text ) {
          
          case 'Category: ' :
            $translated_text = __( 'Something You Like: ', 'wp-post-nav' );
            break;
          case 'Previous Post' :
           $translated_text = __( 'Something Else: ', 'wp-post-nav' );
          break;
           case 'Next Post' :
           $translated_text = __( 'Something Else: ', 'wp-post-nav' );
          break;
        }
        return $translated_text;
      }
      add_filter( 'gettext', 'wp_post_nav_translate', 20, 3 );
    }
    //Text MUST be exact for this to work
    
    Thread Starter andrasch

    (@andrasch)

    Thanks for the reply Jo4nny8 but as I am a beginner I am not quite sure what I have to do.
    Do I have to copy and paste these entries somewhere? Where exactly can I change the text?

    Thank you

    Plugin Author Jo4nny8

    (@jo4nny8)

    @andrasch you need to put the code in either a child theme functions.php file, or you can use one of the many plugins to insert the code to the theme.

    You would need the following to translate the next and previous post text. Simply change the words Something Else to what you want it to be:

    
    function wp_post_nav_translate( $translated_text, $text, $domain ) {
        switch ( $translated_text ) {
          case 'Previous Post' :
           $translated_text = __( 'Something Else: ', 'wp-post-nav' );
          break;
           case 'Next Post' :
           $translated_text = __( 'Something Else: ', 'wp-post-nav' );
          break;
        }
        return $translated_text;
    }
    add_filter( 'gettext', 'wp_post_nav_translate', 20, 3 );
    
    Thread Starter andrasch

    (@andrasch)

    Thank you
    I have changed the text accordingly and pasted the above code in Oceanwp’s Custom CSS, although nothing has changed. Did I do the right thing? If not, can you please recommend a plugin?
    Cheers

    Plugin Author Jo4nny8

    (@jo4nny8)

    @andrasch that won’t work unfortunately.

    Either use the ocean child theme
    Here

    Or find a plug-in. I can’t recommend on as I don’t use theme as you should always use child themes or you can add the codes by creating a custom plug-in which simply has the code in it

    Thread Starter andrasch

    (@andrasch)

    I followed the instructions, exported data, installed the child theme, imported data and then pasted the code to the end in the functions.php. It completely broke my site. Then I pasted the code into the 1st line above everything in the functions.php but then the whole content disappeared, only the header remained. As I said, I am a beginner, not sure why this is so difficult and what I am doing wrong. May be it is better to find another more simple solution for the next/prev button. thanks anyway

    Plugin Author Jo4nny8

    (@jo4nny8)

    @andrasch

    Can you provide me an email address and I’ll email you to get some details to help you out

    Thread Starter andrasch

    (@andrasch)

    xxxxxxxgmail.com

    many thanks

    Plugin Author Jo4nny8

    (@jo4nny8)

    Ive emailed you directly

    This worked perfectly for me, too. Thanks!

    Jo4nny8-
    never mind

    • This reply was modified 11 months, 3 weeks ago by clikzdigital.
    Plugin Author Jo4nny8

    (@jo4nny8)

    @clikzdigital

    Which bit are you struggling with?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Nav button text change’ is closed to new replies.