Add reddit butoon to WordPress
In my previous post, Im writing tutorial for adding digg button to wordpress. In this sort tutorial I will writing about how to add reddit button to wordpress. Reddit are similiar with digg, reddit also provide buttton to integrate with website.
reddit integration code
<script type="text/javascript" src="http://www.reddit.com/button.js?t=2"></script> <script type='text/javascript'>reddit_url='[URL]'</script> <script type='text/javascript'>reddit_title='[TITLE]'</script>
In wordpress themes, we need to replace [URL] and [TITLE] with WordPress’ <?php the_permalink() ?> and <?php the_title(); ?>, and then placing the sourcode within the WordPress loop. You can placing this integration code in index.php, single.php or page.php.
default single.php
<div id="content"> <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <span class="postDate"><?php the_date('F j, Y'); ?> in <?php the_category(', ') ?> by <?php the_author() ?></span> <div class="entry"> <?php the_content('&raquo; &raquo; &raquo;'); ?> </div> <?php comments_template(); ?> </div> <?php endwhile; ?> <?php endif; ?> </div>
Placing reddit button within wordpress loop, before comment_template() tag;
<div id="content"> <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> <div class="post"> <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> <span class="postDate"><?php the_date('F j, Y'); ?> in <?php the_category(', ') ?> by <?php the_author() ?></span> <div class="entry"> <?php the_content('&raquo; &raquo; &raquo;'); ?> </div> <div id="social_bookmarks"> <div class="social_button"> <div class="reddit"> <script type="text/javascript" src="http://www.reddit.com/button.js?t=2"></script> <script type='text/javascript'>reddit_url='<?php the_permalink();?>'</script> <script type='text/javascript'>reddit_title='<?php the_title();?>'</script> </div> <?php comments_template(); ?> </div> <?php endwhile; ?> <?php endif; ?> </div>
By now you have already reddit button on your wordpress. You can also styling the css presentation to make your digg button look more pretty.
This is the css that im using on my wordpress themes.
#social_bookmarks .social_button { background:#f7f7f7 none repeat scroll 0 0; border:1px solid #eee; margin:0; padding:10px; height:100px; } #social_bookmarks .reddit{ background-color:#FFFFFF; border:1px solid #D6D3CA; float:left; margin-left:4px; padding:2px; width:51px; }