Using the WordPress ‘Digg This’ Plugin in Individual Posts

Aviran’s ‘Digg This‘ Plugin for WordPress is a masterful piece of code in use by thousands of bloggers. The plugin requires that you put a line of code in your template. [Not always an easy process to find the right spot.] In theory, this is a great idea as the ‘[tag]Digg[/tag] It’ button doesn’t show up until your post gets Dugg. The plugin even sends you an email when the button first shows up in your post. Cool!

However, as John Chow pointed out recently, you get an ugly red error splotch if your post is Dugg from upcoming stories instead of the story post itself. What can be done? It would be nice to control which posts get the button. However, the ‘Digg This’ plugin does not give you that choice. Normally, you cannot run PHP code from a post. Or, can you? Thanks to another superb plugin by BlueSome named Exec-PHP, you can do just that.

Here is how to do it:

If you don’t have the ‘Digg This’ plugin installed then download, install, and activate it.

Next, download the Exec-PHP plugin, install and activate it from your plugin panel in [tag]WordPress[/tag]. Then, take the code from Aviran’s instructions and put it in your post(s) instead of your template.

Put it in the top, bottom, or both places. I have found that wrapping it in paragraph tags works best here at RL Digital. I put this code right at the end of the post.

Be aware, to use the Exec-PHP plugin – you need to be running WordPress 2.x.

In summary, this technique allow you to control in what posts and where in the post to put the ‘Digg This’ button.

2 Comments