@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
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
@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 );
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
@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
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
@andrasch
Can you provide me an email address and I’ll email you to get some details to help you out
This worked perfectly for me, too. Thanks!
@clikzdigital
Which bit are you struggling with?