0

I'm using blogstart wordpress theme and I would like to change "Read more" text to something similar to language than I'm using. How can I do that? I already tried to paste code below to functions.php.

Replaces the excerpt "Read More" text by a link
function modify_read_more_link() {
return '<a class="read-article" href="' . get_permalink() . '">Your Read 
More Link Text</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

// Replaces the excerpt "Read More" text by a link
function new_excerpt_more($more) {
   global $post;
return '<a class="read-article" href="'. get_permalink($post->ID) . '"> 
Read the full article...</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

Can someone help me with that? Thank you!

2
  • Your code seems alright. It is possible that your theme does not use these filters to output the read more texts/links though. Can you check on a default WordPress theme (like Twenty Twenty) to verify that your code does work there? Commented Jun 20, 2020 at 8:03
  • Hi Coen, thank you for reaching me out. I tried Twenty Twenty, but there is no option of "read more" provided in this theme. Other options like "write a comment" are translated automatically on my language. On other themes that I tried (like Edge) was the same problem with reading More. I found a solution with the code below, but this is not working properly. Comments are fine, but read more still not work properly.
    – Kxml
    Commented Jun 20, 2020 at 10:42

1 Answer 1

0
add_filter('gettext', 'translate_my_text' );
function translate_my_text($translated) { 
$translated = str_ireplace('Leave a comment on: “%s”', 'my text“%s”', $translated);
$translated = str_ireplace('Leave a Comment', 'my text', $translated);
$translated = str_ireplace('Read More', 'my text', $translated);
$translated = str_ireplace('READ MORE', 'my text', $translated);
return $translated; 
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.