One of my goals for this site is to introduce contributing writers to a new audience, and an important aspect of that is to attribute content to the source. A frustration that I have is that despite the fact that over 200 people have contributed to the site, any article that is shared on Twitter is attributed to @leaderswest. So, I started to wonder if I could create a query in the Tweet button (and the Buffer button) that attributes content back to the writer.
Spoiler alert: I did.
There are three steps to this process:
- Set up guests as contributors to your site
- Install Fancier Author Box plug-in
- Insert a PHP query to insert the author’s Twitter handle into the Tweet button
Set-up guest writers as contributors to your WordPress site.
This is probably the simplest thing to do. Rather than post a guest post attributed to you, go to “Add User” and add the guest user as an author to your site. When you input the guest post, go to Author (you may have go to “Screen Options” to enable this) and attribute the piece to the appropriate author.
Install Fancier Author Box plug-in
I use Themato Soup’s Fanciest Author Box for my custom author box, but for those of you who don’t want to spend ten dollars for it, you can download their bare-bones Fancier Author Box for free. If you’re not impressed by the box, you don’t have to use it (opt out on the user screen). What we want from this is their customer Twitter data.
Note that there are ways to do this without using this plugin, but I like to do things free and easy. Plus, their lead developer Slobodan Manic is exceptionally responsive and helpful.
Insert PHP query into share button
To insert a Tweet button on our site, Twitter gives us this code (you should be able to find this for any plugin as well – I did the same thing with Buffer):
<a href=”https://twitter.com/share” class=”twitter-share-button” data-via=”leaderswest”>Tweet</a>
We’re going to ignore everything in the script area and focus on the link. We’re going to substitute a PHP query back of the custom Twitter field from the author box for “leaderswest.” Like this:
<a href=”https://twitter.com/share” class=”twitter-share-button” data-via=”<?php echo esc_attr( get_the_author_meta( ‘ts_fab_twitter’, $user->ID ) ); ?>”>Tweet</a>
And that’s it. Try sharing this post using the Tweet button or the Buffer button and check it out.
Illustration Leslie Ward [Public domain], via Wikimedia Commons