Thursday, December 20th, 2007

Tutorial: Manually Adding Digg Support to Wordpress

What is Digg?

Generally referred to as a social news site, Digg is technically a user-driven news aggregator. Registered Digg users can “digg” (i.e. bookmark and submit) an article on a web page by submitting a URL, along with a brief description. URL submissions are placed on display for other Digg users (registered or not) to read, comment on, rate, and bookmark for themselves.

How Digg can benefit your blog

Two words: heavy traffic. A popular Digg article can easily send thousands of new visitors to a website in a single day. A website does not need an explicit link to Digg in order to receive the benefits of Digg exposure; however, adding a link at the end of every post will give regular and special interest visitors the opportunity to promote an article to a large news-oriented audience. The larger form of the Digg button also specifies the number of times an article has been bookmarked, which can be used as an indicator of its popularity among targeted visitors.

How to add a Digg button to Wordpress Posts

Digg support can be added directly to a Wordpress blog via editing the PHP code for certain files within the blog’s theme. The main challenge is finding the correct files to edit, since Wordpress themes can have different file structures. As such, this tutorial will be more of a strategy for altering a theme to add Digg support. To address most of the common issues users will encounter, a more complicated theme will be altered.

Prerequisites:

  • A Wordpress installation with the ability to edit theme files (generally speaking, online services that do not allow you to upload your own themes also won’t let you edit existing theme files)
  • An account with administrator privileges (required for editing theme files)

dw01-1.jpg

dw01-2.jpg

Login to your site using the URL http://www.yoursite.com/wp-admin, where “www.yoursite.com” represents the root directory of the Wordpress site. Enter the login and password then click on the Login button.

dw02.jpg

Click on the “Presentation” menu item, located on the top menu bar

dw03.jpg

Click on the Theme Editor menu item, located on the menu bar second from the top.

dw05.jpg

Going forward, the exact instructions may differ depending on the theme being used.

In General two pages need to be altered:

  • The page that contains the main “loop” for the front index of the blog
  • The page that displays content for a single blog post

First, look for the index page. The list of available theme files are listed long the right side of the window. It is best to start by searching a file that contains the term index or main index. In the case of this template (Unnamed One 1.0) the best candidate appears to be “Main Index Template”.

Generally speaking, an article link to Digg should be placed directly before or after the content. In Wordpress the content for a post is represented by the Wordpress tag the_content.

Perform a search for the “the_content” in the index page.

dw05.jpg

Unfortunately, for this Wordpress template the content tag does not appear directly in the index page. However, notice there are two PHP include tags for the php pages westagnewstop.php and theloop.php. The latter page sounds like a likely place to find the content tag, since a code loop is used to display each blog post on the front page.

dw06-1.jpg

dw06-2.jpg

Click on theloop.php and once again search for “the_content”.

dw07.jpg

Find the end of the PHP tag containing “the_content” (PHP tags end with the characters ?>). Press the return a key a few times to create space before the subsequent code. Paste the following code in the empty space.

diggcode.jpg

dw08.jpg

Click on the Update File button

dw09.jpg

dw09-2.jpg

Click on the “Preview Site” link at the top of the admin page to preview changes. If the changes were successful, each blog post will be followed by a small digg icon showing the number of diggs that have been performed on the article. The user should also be able to click on the digg icon to submit the blog post to dig. If the blog post already has more than one digg, the region showing the number of diggs should like back to digg.com and shows a description of the article along with any comments from Digg users.

dw10.jpg

At this point, Digg links are available on the site’s index page, but not single-article pages. To add digg links to single-article pages, perform the same tag search and code insertion described above for the single post page. For the template in this example, the page is called “Single Post” but as always the name can change from template to template.

Alternative Methods for Adding Digg to Wordpress

Sociable is a Wordpress plugin that easily integrates bookmarking to multiple social news sites. Bloggers can configure their sites so that each post contains submission links to del.ici.ous, Digg, Furl, Newsvine, Yahoo MyWeb, Slashdot and dozens of lesser-known social news networks. As of writing, Sociable does not support use of the larger and more descriptive Digg buttons; however, its ease of use and support for multiple news sites may appeal to users who prefer an unobtrusive display or do not wish to edit PHP code.

Popularity: 13% [?]

Related Posts:

3 Comments on “Tutorial: Manually Adding Digg Support to Wordpress”


  1. Could you add the code as text rather than an image so we can copy and past the code? Thanks.


  2. Hi Chris. Unfortunately, the text-form of this code is no longer available. Going forward, I’ll be sure to post text copies of all code (e.g. like the SAS Tutorials). Thanks for your input!


  3. You might be interested in free diggs at http://www.eeeb.org. Get free diggs there for any of your digg urls - Mrmichaels Dpfriend

Leave a Reply