Archive for the Code Category

Wordpress: Category sensitive Digg links

Posted on Friday, August 28th, 2009 at 2:55 pm

I wanted to add Digg links to all the pages in specific categories.  Smashing Magazine had a trick for adding Digg links based on custom fields, which is great if you are the person who can remember to add the custom fields.  I’m not.  Here’s a modified code snippet that you can add to your single.php file, to produce a Digg button on all pages in a list of categories:

<?php
   if (in_category( array('category1', 'category2', 'etc'))){
      echo '<script src="http://digg.com/tools/diggthis.js"
      type="text/javascript"></script>';
   }
?>