Change button text
-
There are 2 main buttons on the main page of this theme:
Contact me
Download resumeCan somebody tell me where to change te text of these buttons? I would like to translate them to Dutch language
-
Hello Hendrys,
You can change those two texts by using a WordPress function which translates texts (https://codex.ww.wp.xz.cn/Plugin_API/Filter_Reference/gettext).
For example:
To change ‘Resume’ to ‘Resumé’, just add the below codes inside ‘functions.php’ of child theme.add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 ); function theme_change_comment_field_names( $translated_text, $text, $domain ) { if ( is_singular() ) { switch ( $translated_text ) { case 'Contact Me' : $translated_text = __( 'Neem contact met mij', 'Bizlight' ); break; case 'Download Resume' : $translated_text = __( 'Download Resumé', 'Bizlight' ); break; } } return $translated_text; }Note: This function translates all the matching text to the translating text allover the theme.
Also,It is recommended to create child theme if you are going for the coding option else your changes won’t be saved when you update the theme. For that: https://codex.ww.wp.xz.cn/Child_Themes#How_to_Create_a_Child_ThemeLet me know how it goes!!
Would I use the same code to change “Contact me” to “Contact Us”, or is there a simpler way?
Hello @camasurich,
Yes, you can use like the one shown in the above example. Try it and let us know if it worked.Thanks,
I created a child theme and it looks likes the theme works. But I cannot get the translation to work. What do I wrong?
functions.php:
<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 ); function theme_change_comment_field_names( $translated_text, $text, $domain ) { if ( is_singular() ) { switch ( $translated_text ) { case 'Contact Me' : $translated_text = __( 'Neem contact op', 'Bizlight' ); break; case 'Download Resume' : $translated_text = __( 'Mijn CV', 'Bizlight' ); break; } } return $translated_text; } ?>Do I need to install additional plugins to get it to work?
Hello @hendrys,
Can you share your site url.
You don’t need to install third party plugins to change the button texts.
The above code is working well on the theme. You can see the output here:
http://prnt.sc/acknfsRegards.
Hello Wen Solutions,
The site URL is https://www.scholing-online.nl
@hendrys, your child theme is working well.
Change the code inside functions.php to as shown below:<?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 ); function theme_change_comment_field_names( $translated_text, $text, $domain ) { switch ( $translated_text ) { case 'Contact Me' : $translated_text = __( 'Neem contact met mij', 'Biography' ); break; case 'Download Resume' : $translated_text = __( 'Mijn CV', 'Biography' ); break; } return $translated_text; }Let us know how it goes.
RegardsThis code works, thank you very much!
The topic ‘Change button text’ is closed to new replies.
