Doesn’t it get
annoying posting digg buttons on your articles every time. But you don’t want to display them on every page by default because some articles are not digg worthy. Well this solution would be very helpful then. In this plugin, you will add the codes in your single.php once, and in each article that you want to
display the button, you will just have to enable it using the custom field.
First open your single.php and find a code that looks like this:
1 | <?php if (have_posts()) : while (have_posts()) : the_post(); ?> |
Replace it with:
1 | <?php if (have_posts()) : while (have_posts()) : the_post(); |
3 | $digg = get_post_meta( $post ->ID, 'Digg' , $single = true); |
Now you need to add the following code within the loop anywhere you like:
3 | <script src= "http://digg.com/tools/diggthis.js" type= "text/javascript" ></script> |
You may wrap it around with any styling that you want. Save the single.php and upload it to your theme folder.
Now when writing a post if you want to add a digg post simply add a custom field like shown in the screen shot below:
Whenever you specify this custom field, WordPress will display a digg button on your post.
No comments: