Social sharing on blog posts

Hi there! :slight_smile:

So, I just added this to my functions.php to enable social sharing on my blog posts:

function x_add_social_sharing() {
if ( (!is_front_page() && is_home()) || is_single() ) {
echo do_shortcode(’[x_share title=“Partagez cet article !” facebook=“true” linkedin=“true” email=“true”]’);
}
}
add_action(‘x_before_the_content_end’, ‘x_add_social_sharing’);

It does work well, but I was wondering: is there anyway to make the text different when you hover them? Because it’s saying “share this article” in english and I’d like it to be in french; same thing for the email share, it’s in English and I’d like to make it all french. :slight_smile:

Thanks already for your help!

Hi there,

You could translate the text by adding this code in the functions.php file of the child theme:

add_filter('gettext', 'x_translate_text' , 20, 3);

function x_translate_text ( $translated_text, $text, $domain ) {
	
	$translated_text = str_ireplace("Share on Facebook", 'THE_TRANSLATION_TEXT_HERE', $translated_text);
	$translated_text = str_ireplace("Share via Email", 'THE_TRANSLATION_TEXT_HERE', $translated_text);
	$translated_text = str_ireplace("Share on Google+", 'THE_TRANSLATION_TEXT_HERE', $translated_text);
	$translated_text = str_ireplace("Share this Post", 'THE_TRANSLATION_TEXT_HERE', $translated_text);

	return $translated_text;

}

Please substitute THE_TRANSLATION_TEXT_HERE with the correct translation text.

If you don’t have the child theme installed yet, you can get it from here: https://theme.co/apex/child-themes

Once you have it installed and activated, you can login through FTP and go to wp-content/themes/x-child and you should find the functions.php file there.

Hope this helps.

Awesome thanks! Just installed the child theme, thanks for that too.

Another question regarding the blog just occurred to me while checking if it worked… When I look at the preview, I can see that it says “READ MORE” (see picture below). Is it possible to also translate that?

Thanks!

Picture:

Hello @Fuzuki,

Thanks for updating the thread.

You can add following code in child theme function.php file:

add_filter('gettext', 'translate_text' );
function translate_text($translated) { 
  $translated = str_ireplace('Read More', 'Enter Text here', $translated);
  return $translated; 
}

Please replace Enter Text here.

Child theme resource:

https://theme.co/apex/child-themes

Thanks.

Perfect, thanks a lot!

Have a great day/night! :slight_smile:

Hi @Fuzuki,

Have a great night/day also:slight_smile:

Feel free to ask us again.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.