Family Encyclopedia >> Electronics

How to add a Digg button in your WordPress using custom fields

You will see that many sites add a digg button within their post content. Some new users just open single.php and add the digg script which will make a digg button appear on all blog posts. But what if you want to show the digg button only on specific posts? You can manually add it on each post when writing a post, but that's not the most efficient way. In this article, we'll show you how you can add a dig button on specific posts by using custom fields.

First open your single.php and find a code that looks like this:

 

Replace it with:

 ID, 'Digg', $ single = true); ?> 

Now you need to add the following code inside the loop anywhere you want:

 

You can wrap it in any style you like. Save the single.php and upload it to your theme folder.

Now when writing a post, if you want to add a Digg post, just add a custom field as shown in the screenshot below:

How to add a Digg button in your WordPress using custom fields

When you specify this custom field, WordPress will display a digg button on your post like this:

Take a look at this example (live)