Press "Enter" to skip to content

WordPress: Category sensitive Digg links

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>';
   } 
?>  

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.