Many of you probably share their new blog post on social media platform like Facebook, Google+, Twitter and others. I also do that, but I always post them manually with a nice custom message. But sometimes you need to have a more automated way to post to those platforms. Especially when you publish a lot of content and/or you are sharing on many platforms. Then you might want to use one of the many automatic sharing plugins around.
Social media postings with the Jetpack Publicize module
On a client’s website, we’ve used Jetpack for the sharing. Once you’ve activated the Publicize module and connected to some services, you will with a new setting in the “Publish” metabox. Clicking the “Edit Details” link, you will see a new textarea, where you can set the custom message to be used when shared. It looks like this:
As you can see, the “Custom Message” is the title of the current blog post. You can change it here manually, but wouldn’t it be nice, if it would be something more meaningful, by default (and in case, you forget to edit it, before publishing)?
Changing the default message
On my search for a simple solution I’ve found some older blog posts. But the method either doesn’t work anymore, or just not in the setup I had. They also changed the value, when the post was saved. Therefore, I would not have been possible to change the text using the metabox anymore. I finally came up with a solution, that changes the text only when creating a new post and no value has yet been saved. The solution is as simple as this little snippet:
function set_jetpack_publicize_default_message() { global $post; if ( ! empty( $post->ID ) ) { if ( ! $wpas_title = get_post_meta( $post->ID, '_wpas_mess', true ) ) { /* translators: %s: the name of the blog */ $custom_message = sprintf( __( 'Check out this new awesome blog post on %s!', 'set-jetpack-publicize-default-message' ), get_bloginfo( 'name' ) ); update_post_meta( $post->ID, '_wpas_mess', $custom_message ); } } } add_action( 'post_submitbox_misc_actions', 'set_jetpack_publicize_default_message' );
The function checks, if a sharing default message is already set, and if not, it will set a nicer one for us. But this new message is still editable and as soon as the message was set once, it will not change it again.
Conclusion
A small snippet and your sharing messages will look a lot nicer than before. But for myself, I stay with the method of posting each social media message individually. This way, I can create an optimal 140 characters message for Twitter and a larger one for the other social media profile.
How do you share your blog posts on social media? Do you use Jetpack or another plugin? Do you use any external tool or service? Or do you post them manually on your social media profiles and pages?
Thanks for sharing. Could only find docs on manually changing the message every time. This is way better and worked for me!