WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

May 03 2011

How to Add a Twitter Share Button to Your Post Info in Genesis

Simply add the following code to your functions.php file.

[php]// Modify Post Info
add_filter('genesis_post_info', 'my_post_info_filter');
function my_post_info_filter($post_info) {
if (!is_page()) {
$post_info = '[ post_date] By [ post_author_posts_link] [ post_comments] | Share: <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> '; //remove spaces after initial [
//$post_info = 'Custom text'; //edit this to whatever you'd like.
}
return $post_info;
}[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. Paul says

    September 29, 2011 at 7:43 pm

    This isn’t working for me. I’ve copied and pasted it into my functions.php file and still nothing.

    Reply
  2. Nick says

    October 16, 2011 at 9:02 am

    Oh thanks! I was looking for days about how to do this… Found it here finally by googling ‘post info tweet button’ after seeing that Christopher of Genesis Tutorials had it in the Visual Hook Guide.

    There is an error in this code though… The end of it… </script&gt

    With this code I think I’ll be fine to add more social buttons next to post info as well…

    Reply
  3. Nick says

    October 16, 2011 at 9:20 am

    I’ve fixed the code and gotten it working on my site.

    Now I’d like to know how to get the button to be aligned over to the right, rather than butted up next to the post info text. I’ve tried float: right on all the Twitter button classes/ids but it just messes it up rather than doing the job of moving it across to the right edge.

    Here is the fixed version:

    // Modify Post Info
    add_filter(‘genesis_post_info’, ‘my_post_info_filter’);
    function my_post_info_filter($post_info) {
    if (!is_page()) {
    $post_info = ‘[post_date] by [post_author_posts_link] [post_comments] | Share: Tweet‘; //remove spaces after initial [
    //$post_info = ‘Custom text’; //edit this to whatever you’d like.
    }
    return $post_info;
    }

    Reply
  4. Blogging Tips says

    March 20, 2012 at 1:38 am

    Not working for me !! and can I add facebook like button too ?

    Reply
    • Travis Smith says

      April 2, 2012 at 8:15 am

      Please check http://twitter.com/about/resources/buttons for the most recent and up-to-date Twitter code to use.

      Thanks,

      Travis

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in