plugins - How to change "Read More" text?

admin2025-01-08  6

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!

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!

Share Improve this question asked Jun 19, 2020 at 20:34 KxmlKxml 93 bronze badges 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? – Coen Jacobs 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
Add a comment  | 

1 Answer 1

Reset to default 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; 
} 
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736266727a1143.html

最新回复(0)