Add Reddit, Stumbleupon, Delicious, & Digg Submit Buttons to WordPress

Add Reddit, Stumbleupon, Delicious, & Digg Submit Buttons to WordPress.pngI spent all of this morning trying to find a good article to help me get Reddit, Stumbleupon, Delicious & Digg on my homepage as well as on each individual blog post, but I couldn’t find any good resource.

Everything was just spammed-filled crap, so after spending the good part of this morning on this issue, I finally have a good solution for filling in these popular bookmarking services.

The code I used was simple, I took each submit button separately, used the WordPress codex for the PHP calls and slapped together the 4 best looking buttons for the project. Here is the code to insert it into your WordPress blog, other blogs can use this code, but you’ll have to modify the PHP for your particular install:

Digg

  • <script type=”text/javascript”> digg_url = ‘<?php the_permalink() ?>’; </script> <script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”></script>

Reddit

  • <script>reddit_url=’<?php the_permalink() ?>’</script> <script>reddit_title=’<?php the_title(); ?>’</script> <script type=”text/javascript” src=”http://www.reddit.com/button.js?t=3″></script>

Delicious

  • <a href=”http://del.icio.us/post?url=<?php the_permalink() ?>&title=<?php the_title() ?>” title=”Submit to Del.icio.us” target=”_blank”><img src=”http://wisestartupblog.com/wp-content/uploads/2008/07/delicious.42px.gif” style=”padding: 0px 5px 14px 3px;”></a>

StumbleUpon

  • <span style=”vertical-align: 95%;”>
    <a href=”http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>”><img src=”http://wisestartupblog.com/wp-content/uploads/2008/07/32x32_su_solid.gif”></a>

For StumbleUpon, I had to use some styling elements to get the buttons inline with the rest of the icons, without the styling the StumbleUpon button will be in the bottom margin and look like crap.

To install these buttons, you need to insert the code somewhere in the “index.php” and “single.php” file, I inserted mine directly above: