Put a Floating Digg Badge in Your Posts
Next thing I figured I needed was a way to link into the social networking sites. You can download a plugin to display the most popular user submit tags from the WordPress plugin directory, but i didn’t see a plug in to put the new Digg badges in your posts. You know like the one you see in this post. So i did what any self respecting MacGyver would do… get into the code.
You can edit the template files in your WordPress admin or with a text editor. Use whichever you’re comfortable with. i just used the WordPress editor since it was a quick and simple fix. Open the index.php file and find this line of code..
<?php the_content(__(’Read more »’));?>
Add the following code right above that line.
<div style=”float:left;margin-right:5px;”><script type=”text/javascript”>
digg_url = ‘<?php the_permalink() ?>’;
</script>
<script src=”http://digg.com/tools/diggthis.js” type=”text/javascript”>
</div>
This is the generic digg badge code, the only thing of note is the ‘dig_url’ variable. It calls a WordPress method to set the url for digg to the permalink of the post.
Now do the exact same with the file ’single.php’. This way the badge will appear on the main page of your blog as well as the single entry page.
Related Articles:
- Different approach to mananging your bookmarks
- Setting Up Your First Blog Thing
- Use StumbleUpon Over Digg For Visitors
One needs to be careful with the style of css when overriding the styles. This code caused confusion between the sidebar and the main section of my wordpress theme.
I will play with this code and let you know what works for my template.
As long as you put the badge div container within the main entrybody div it should work okay.
There is something funny with this code that I modified, maybe it is because I am an amateur at css, but adding your code still does not work.
The code turns my page into the “header”, “post title”, and then the “sidebar” directly beneath the post title.
Here is how the code looks in my index.php:
I will keep playing as well as keep you updated… now it’s time for me to get back to work.
Thanks! I just used the code on my site. The character encoding gave me a little problem. If someone else has a problem getting the badge to show up, try deleting all of the ” and ‘ and replacing them. It worked for me.
Testosterone too much….
How to purposely lower your testosterone level. Testosterone. Low testosterone….