Hi,
I’ve added the Social Share Buttons element to the foot of my blog:
but when I click the Twitter button to share the post, two things don’t seem to be working:
1) The page URL is displayed in the tweet as http://corrinagordonbarnes.com/?p=3367. Yes, this links to the correct blog post but I want it to display the proper URL as above. The settings within WordPress are correct for this.
2) It displays the title of the post but not the meta description that I’ve set within the Yoast plugin.
Do others have this same problem? Is this a glitch with the Twitter aspect of the Social Share buttons, or is there some setting I can change to remedy this?
Many thanks
Corrina
Hey!
1. Enfold uses the shortlink version of the post so it uses less characters.
2. Yoast description is not connected to the theme’s social sharing function by default.
Luckily, the social sharing arguments can be modified by the user with the help of a filter, try adding this at the very end of your theme / child theme functions.php file:
add_filter('avia_social_share_link_arguments', 'avia_add_social_share_link_arguments', 10, 1);
function avia_add_social_share_link_arguments($args)
{
global $post;
$yoast_desc = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true);
$args['twitter'] = array("encode"=>true, "encode_urls"=>false, "pattern" => "https://twitter.com/share?text=$yoast_desc&url=[permalink]");
return $args;
}
Cheers!
Josue
Thanks so much for helping out with a solution, Josue.
Is this code I add in the Quick CSS box? Or do I need to pass this to my tech guy?
It would probably better to do the latter, the code can be placed in theme / child theme functions.php.
Best regards,
Josue