You’ll notice that I’ve got this feature active on the site now. If you scroll down to the comments section, you, or any commenter can add his/her twitter handle that will attach to the comment.
Since I am using the Hybrid Theme, this tutorial is for it.
#1
First off, we need to grab the latest version of Twitter Link Comments. And of coarse be sure you’ve got the Hybrid Theme (version 0.8.x or greater) installed and activated. With Hybrid 0.8, you’ll need the latest trunk version of WordPress, which as of today happens to be 3.0, beta-2
#2
Ok, now that’s settled, I hope ;). We can move on the the options that Twitterlink has. Below you’ll see a bases for what you need to apply. We’ll turn off auto add twitter field, and apply the style and setting to how we want the link formation to be.
#3
Next, will moving into our functions.php
file located in your child theme. No child theme being used? Well at the end of this tutorial will apply this function into a plugin!
Paste this function.
function add_twitter_id_field($fields) { $twitlink = get_option('twitlink'); $fields[] = '<p class="form-twitter"><label for="twitter">Twitter <span class="required">* <em>Don′t use the @ symbol</em></span></label><input type="text" class="text-input" name="atf_twitter_id" id="atf_twitter_id" value="' . esc_attr( $twitlink['post_html'] ) . '" size="40" tabindex="4" /></p>'; return $fields; }
That’s it, the whole function. Now be sure to add the appropriate filter, which is:
add_filter( 'comment_form_default_fields', 'add_twitter_id_field' );
This function will filter in the new input with the ID of atf_twitter_id
which the plugin Twitter Link Comments looks for to apply it’s twitter field magic.
Now, I’ve noticed that when an end user, or commenter comments multiple times that if inputting a different twitter handle the newest and latest gets applied to all previous comments. I sure there is a way around that, I’ve just not looking into it.
#done
Um, that’s a number, some times.
Anyway, that’s all you’ve got to do to add to add your users twitter handle and attach it to their comments.
Leave a comment below, and test it out!
Thanks for your writing. I’m using hybrid as plataform and now i’m looking forward for your next posts and tuts.
Very nice tutorial. I love the Hybrid framework too. It’s very powerful, and easy to use. Thanks for sharing a great tip.
[…] wanted more in depth tutorials and tricks on another domain. @WPWag came in and great posts like Adding a twitter field to comments in Hybrid & Extending the WordPress admin_body_class, just to name a few…Short […]
thanks to this post I found what I was looking for. Awesome!