Home » How To, Web

How to add Digg button in WordPress without Plugin

Posted by: 14 January 2011 3 Comments

Digg is one of the largest content sharing site nowadays. It allows people to discover and share content from anywhere on the web. The Digg button, also known as “Digg this” button, is for blogs and website to share content on Digg.

There are many  WordPress plugins available for putting digg button on WordPress blog or site; all of them are workable. This blog post guide you how you can add Digg button without plugin on your WordPress blog. If you want to add Digg button on your WordPress site all you need to do is put the following code in your theme where you want.

Here’s code for adding “Digg this” button on home page.

<a href=”http://digg.com/submit?url=<?php the_permalink()

?>&title=<?php the_title();?>&bodytext=<?php the_excerpt(); ?>”</a>

<script src=”http://widgets.digg.com/buttons.js”></script>

Now use the following code for the small and long button on a single post

<a href="http://digg.com/submit?url=<?php the_permalink()
?>&title=<?php the_title();?>&bodytext=<?php the_excerpt(); ?>"</a>
<script src="http://widgets.digg.com/buttons.js"></script>

The Digg button is available in four sizes: Wide, Medium, Compact, and Icon

Digg Button How to add Digg button in WordPress without Plugin

To use any of them on your blog or site you need to specify the button size in anchor class, as given below.

<script type="text/javascript">
(function() {
var s = document.createElement('SCRIPT'),
s1 = document.getElementsByTagName('SCRIPT')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://widgets.digg.com/buttons.js';
s1.parentNode.insertBefore(s, s1);
})();
</script>
<!-- Wide Button -->
<a class="DiggThisButton DiggWide"></a>
<!-- Medium Button -->
<a class="DiggThisButton DiggMedium"></a>
<!-- Compact Button -->
<a class="DiggThisButton DiggCompact"></a>
<!-- Icon Button -->
<a class="DiggThisButton DiggIcon"></a>

Do let us know if you found any problem during adding this code in comments section?

Follow us on Twitter or join our Facebook fanpage for latest Tech News and Tutorials.

Advertisements
Subscribe to TecRux: Subscribe to RSS Feed or get latest updates in your Inbox.
Note: * Click confirmation link sent in email * Don't see the email, check spam folder


Related Posts

 

Article by

Faisal has written 33 awesome articles.

If you liked this post, you can follow TecRux on Twitter.

Subscribe to feed via RSS or EMAIL to receive instant updates.

  • Tomi

    Hi, I just read through your tutorial, but as a novice I don’t understand the process. I don’t know which files to paste the codes in (index.php or hooks.php or whichever).

    Kindly do a video on this process. I don’t want to use a plugin just for a digg button in my posts.

    Thank you in advance?

  • http://www.tecrux.com/ Usman

    You can copy the code given above and paste on whichever page you like, if you have a blog you can add it in the single.php page. for home page add the code index.php

  • Anonymous

    Thanks, that’s what i needed