Tagged: Blog, change text, read more, text
-
AuthorPosts
-
June 6, 2022 at 2:35 pm #1354308
Hello, under all my blog items there is a “Read more” button (which I want to keep). But I want to change the text “read more” in something else.
How can I do that in my Child theme (so that it is not changed back after an update)/
Thanks for your help :)
Best Wishes,
AlwinJune 7, 2022 at 8:14 am #1354352You can of course edit all loop files that are affected and upload them as child-theme files.
Unfortunately, this is quite a lot of places to change, due to the fact that we have different cases here.
(Business-, Elegant-, Business-modern Blog) and that in loop-index.php, loop-portfolio-single.php etc.but you can try this substitution via gettext:
function my_text_strings( $translated_text, $text, $domain ){ switch ( $translated_text ){ case 'Read more' : $translated_text = __( 'Read more of it', $domain ); break; // in case you got different languages on your page and want to change them too: case 'Weiterlesen' : $translated_text = __( 'Mehr über das Thema …', $domain ); break; } return $translated_text; } add_filter('gettext', 'my_text_strings', 20, 3);
June 13, 2022 at 12:08 pm #1355027Thank you Guenni007,
– Do I have to place your code in my Child themes functions.php file?
– I don’t have different languages on my page, so I can skip that part of the code?
The text needs to be translated in German; “Mehr lesen”. So would it have to be like this:
function my_text_strings( $translated_text, $text, $domain ){ switch ( $translated_text ){ case 'Read more' : $translated_text = __( 'Mehr lesen', $domain ); break; } return $translated_text; } add_filter('gettext', 'my_text_strings', 20, 3);
Thanks a lot again :)
Best Wishes,
AlwinJune 13, 2022 at 1:39 pm #1355038Yes for child-theme functions.php
and this second line was only meant to show how further substitutions have to be set. Important is the break setting after each line.
– However, if you had asked for a different language translation ( f.e. the german translation of the read more phrase) , I probably would have recommended editing the lang file. Again, you could find a child theme solution.June 13, 2022 at 3:20 pm #1355049I added the code to my fuctions.php and it’s working fine!
Thank you again 007 :)
Alwin
June 13, 2022 at 5:06 pm #1355056Hi,
Great, I’m glad that @guenni007 could help you out. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
Rikard -
AuthorPosts
- You must be logged in to reply to this topic.