after-header

Creating a Digg Button that actually works in WordPress

Getting the right code to add a Digg Badge that automatically populates the submission information onto my WordPress blog was a challenge, but I managed it! Here’s how I accomplished the task.

It should have been simple thing, I wanted to add a Digg button to my blog to make it easier for my visitors to Digg my posts. I was alarmed to find that none of the code snippets that I could find, including those on the Digg Website seemed to work. After hunting around for awhile I found that the single quotes in the sample code available from Digg was the first piece that need to be corrected. Eventually, through trial and error, I was able to find WordPress template tags that gave me the results that I was looking for.

The code for the Digg badge can be copied from here directly into your WordPress theme templates. Usually in the index.php, single.php, and archive.php. For my own theme I chose to put the code in right after the call for “the_title” You should also note that this code is written specifically to be placed within “the_loop” The code for placing a Digg badge in a sidebar, header or footer, would be different.

The basic code:


 

What the code does:

  • This code uses the post’s permalink as the url that is being submitted to Digg.
  • The post’s title and the first 40 words of the post will be pre-filled on the Digg submission screen
  • Optionally, the Digg topic, badge background color, badge type(skin), link target can be set (see below)

On the my front page I wanted a Compact Digg badge. I didn’t like having so many large badges on the front page but I also didn’t want to completely eliminate the badge. All of the preset information can be modified prior to submission by the individual doing the first Digg. I set the code within it’s own div with a class of “diggbadge” so that I can modify the way the badge displays using CSS. The code for a compact badge with the Digg topic of “software” preselected with a link that opens a new window:

 

The code for a full size badge with the Digg topic of “software” preselected with a link that opens a new window:

 

There are other options that can be added in the code as well:

digg_bgcolor = "#ff9900";
digg_skin = "compact";
digg_window = "new";
digg_topic = "software";

digg_bgcolor sets the background color of the Digg badge. This value will change the background color around the outer edge of the button. If omitted, the default color is white. Any valid CSS color can be entered here.

digg_skin defaults to the full size badge, by setting the value to compact you can have a smaller badge displayed on your site. I like this for pages with multiple posts such as the front page or an archive page. the value of “icon” can also be set which will display a 16X16 icon instead of a badge.

digg_window sets the target of the link. A value of “new” will open a new window when the badge is clicked.

digg_topic sets the topic that the post will be filed under on the Digg site. If you have a consistent topic that your posts fit within this is an additional help for those that might want to Digg your site. The value can be changed from the submission screen by the person Digging your post. The value set here must be one of the topics in the following list:

  • 2008_us_elections
  • apple
  • arts_culture
  • autos
  • baseball
  • basketball
  • business_finance
  • celebrity
  • comedy
  • comics_animation
  • design
  • educational
  • environment
  • extreme_sports
  • food_drink
  • football
  • gadgets
  • gaming_news
  • general_sciences
  • golf
  • hardware
  • health
  • hockey
  • linux_unix
  • microsoft
  • mods
  • motorsport
  • movies
  • music
  • nintendo
  • odd_stuff
  • other_sports
  • pc_games
  • people
  • pets_animals
  • playable_web_games
  • playstation
  • political_opinion
  • politics
  • programming
  • security
  • soccer
  • software
  • space
  • tech_news
  • television
  • tennis
  • travel_places
  • world_news
  • xbox

I hope that this demonstration will be useful! Don’t forget to use the Digg badge up at the top of the post! I’ve done all I can to make it easy for you! For my loyal readers using a feed reader, come on over to the site to see the badges in action. Report any problems with the code snippets back to me!

4 WordPress plugins for comprehensive spam prevention on your blog

Happy Birthday, Spam!Anyone that has been blogging for more than a couple of months will be able to tell you that comment spam can be a real problem. Here are 4 plugins to be used together to prevent nearly all spam for your blog. This is achieved by checking for potential spam using a variety of different methods. These plugins do not resort to annoying and hard to read Captcha images or other methods that require your visitors to prove that they are really humans.

  • Akismet – this plugin is automatically packaged with WordPress so there is nothing to install. This plugin will catch nearly all of your spam but can also catch false positives so it’s a good idea to keep an eye on your spam comments to make sure that legitimate comments are not accidentally banished to the spam box. In order to use the plugin, though, you must have a WordPress.com API key. This key is obtained by signing up for an account on WordPress.com. Akismet is developed by Automattic Inc and is free for personal blogs that do not generate “significant income” from their blogging. “Significant income” is defined as more than $500 per month. Commercial API keys can be purchased for commercial blogs and those not eligible for a personal license due to income level.
  • Bad Behavior – works along side other spam prevention plugins to look at not only the content of the comment but also the way the comment was created, prevents many automated commenting methods from getting through the other spam software content filters.
  • Simple Trackback validation – This plugin specifically checks trackbacks for possible spam. First it checks to be sure that the IP address that the trackback is requested from is the same as the IP address of the server where the requesting website is located. This catches a large portion of trackback spam since valid trackbacks are almost always pinged directly from the webserver where the other website is located. This plugin will also verify that the backlink to your website actually exists on the website that sent the trackback.
  • Email Obfuscator – this plugin protects any email addresses that might be in your blog posts by either using JavaScript to confuse email scrapers or, for browsers with javascript disabled, the email address is displayed as a fake address and the actual address can be viewed using a mouse hover to display the real email address.

Spammers are not likely to stop attempting to get their comments and emails through the defenses that you put in place to keep them out so it’s a good idea to stay on top of the current plugins available to keep the comments from appearing on your website.

I’d love to hear about how others handle spam commenting and about new and improved ways of keeping the spam out. Leave a comment if you are aware of other great tools and plugins!

Creative Commons License photo credit: billypalooza

Using the WordPress blogroll/link system to display website badges and buttons in your sidebar

Question of the day: How can I display linked images for other websites and blogs in my sidebar?

Answer: With the Links/Blogroll system already built into WordPress along with a Sidebar Widget! Here’s How:

I’ve seen this question asked many times. Most WordPress users assume that the blogroll/link widget using the integrated links system in WordPress will only display text links so many people use text widgets to paste HTML code for simple image links to other websites. Here is an alternative to the text widget method.

  1. You will need to have a url that points to the image that will be displayed in your sidebar for the image link. Most bloggers prefer that you host these images yourself. You can use the image hosting of your choice so long as the image is accessible via a regular URL. You will just need to know the full URL to the location of the image file.
  2. Next you will add the link to WordPress. From the WordPress 2.5 dashboard you can go to the “Write” tab and then choose the “Link” sub-tab.
  3. Complete the basic link information
    • Name - This is the text that will display if an image is not present for the link
    • Web Address – This is the URL that will be loaded when your link image is clicked.
    • Description – This is designed to give more information about the link. It is not as widely used as the Name but if you plan to create a good links page at any point I suggest including this information.
    • Category – This is important if you want your sidebar widget list to separate different types of links into categoriesAdd Link Basic Options
    • Advanced Options
      • Target - This is where you set whether you would like the link to open in a new window or the same window.
      • Link Relationship – This is an area that I have not explored but I plan to write a future post about the information set here can be used.
        Add Link Advanced Settings
      • Advanced – This is where you set up the image information!
        • Image Address – Enter the full address to the image, which you should have from Step 1
        • RSS Address – Link some of the other option this is not used as widely but entering this gives you future access to this info
        • Notes – You can add notes to yourself here. Want to be able to remember why this link was worth adding, enter the reason here.
        • Rating – Another option that can be used in certain situations, does not display in the standard links widget
          Add Link Advanced Options Cont.
  4. Go to the Design Tab then to the Widgets sub-tab to add the Widget to your sidebar. Click the “Add” Link on the Links Widget on the left side of the screen, Drag the widget to the spot you would like the widget to be on your site and click save.
    Completed Link Widget with Image Link

This is the most basic application of this solution. The Link widget included with WordPress does not allow any modification in terms of which link categories display, which pieces of information to display, or to change the sort order of the links.

Some more flexible Link Widget options:

Reasons to Upgrade to WordPress 2.5 and beyond

I’ve had several people ask my for reasons to upgrade to WordPress 2.5 instead of staying with an older version. I happen to like the new interface, and the new image handling system shows a lot of promise. There is one overwhelming reason, in my opinion, to stay up to date with the most current version of WordPress whether you like the cosmetic features or not. It all boils down to security. Each version of WordPress closes up gaps that hackers can use to weasel their way into your site. Some might fill the hidden corners of your site with spam links, which will trash your search engine standing without you even realize anything has happened. Other hackers can do more serious damage. A site I manage was hacked, recently, in order to use the site as a portal for illegal file downloads. I don’t want to leave any holes that they can get through if there is a readily available fix.

In case security is not enough of a reason for you to upgrade, here are a few others to think on:

  1. Once you get accustomed to it, the new backend interface actually makes more sense. Things are grouped together more logically and the things most bloggers use the most are given more exposure on the page. Things used less often are put in a more out of the way location on the screen. It’s not perfect and there are a few inconveniences here and there but overall the improvements outweigh the problems.
  2. The new image handling system has a lot of potential. I don’t think it’s quite there yet in terms of features but with a few tweaks it has the potential of being a really functional way of handling images and galleries in WordPress. Even without all the features I can envision being implemented it’s a huge improvement over the way things were handled in previous versions.
  3. Plugin Authors are moving on. Staying current with plugins is important and actively developed and new plugins will be coded with 2.5 in mind.
  4. Things will only move forward from here. While upgrading across several versions of WordPress is not impossible it’s much better, in my opinion, to keep the system structure as close to current as possible.

I stand behind the development process of WordPress and once you get past the initial shock of a big visual change you won’t even remember that old dashboard after awhile.

If upgrading your WordPress installation is a challenge to daunting for you to contemplate contact me. For a reasonable rate I can bring your WordPress installation up to the current version and, if necessary, make sure that nothing else breaks in the process.

9 Things to consider before using a new WordPress Theme

If you have been using WordPress you probably know that there are thousands of very nice and freely available themes that you can use to skin your WordPress blog. What you might not realize, though, is that you should take a look under the hood of a theme before you put it into live duty on the blog that you have worked hard to build. Here are some things to take a look at:

  1. Sidebars – Widgets or Hardcoded

    The drag and drop nature of the WordPress Widgets are much easier for the casual blogger to manage but many power users prefer the old fashioned hard coded sidebar system. If the theme you are considering is not widget ready and you would like to use widgets you will need to add the necessary code to activate the widget system. Here are a couple of useful links for making a non-widget theme widget friendly.

  2. Page Navigation Bar Dynamic or Static

    If the Theme you are considering has horizontal navigation links to pages it will be helpful to determine whether the links are coded for specific URLs or if they will be automatically generated based on the pages that you have created for your blog. Changing hard coded links to dynamically created links may require changes to both your CSS Style sheet and your header.php file.

  3. Page Navigation for sub-pages

    If the theme generates the horizontal navigation links for your site automatically you may also want to know how sub pages will be handled. Depending on the way the navigation is coded and how the CSS stylesheet is constructed you may either find your subpages listed on the same level as your top level pages, listed as CSS dropdown menus when hovered over, or completely omitted from the horizontal navigation.

  4. Adsense or other Advertising built in?

    If the theme comes with adsense code already included keep in mind that it’s not going to bring you any income if you don’t change the publisher code to your own information. The way this is handled varies from theme to theme. Some themes will have a file that contains only the publisher code so that the code can be change site-wide easily. Also remember that it is against the Adsense terms of service to display more ads from more than one publisher code on the same page so if you plan to insert your own ads in another way you need to be certain you have either change the code in the hard-coded ads to match or to disable the hard-coded ad spots.

  5. Built in RSS Feed Links in the meta data

    I’ve come across several blogs with problems with the RSS links on their sites. Often, the visible links on the site are correct but the link in the meta data is wrong. Since many people will subscribe to a feed in ways that will utilize this meta data URL instead of the visible feed URL on your site it’s important that this be accurate. The code for this is usually located in the header.php file in your theme. and should look something like this:

    <link rel=”alternate” type=”application/rss+xml” title=”<?php bloginfo(‘name’); ?> RSS Feed” href=”<?php bloginfo(‘rss2_url’); ?>” />

    This code pulls the information for the feed URL from WordPress rather than having it hard coded. Much better, in my opinion.

  6. Tag Support

    Tags, not to be confused with categories, are a great way to organize your content in a variety of different ways. They are also very SEO friendly. WordPress 2.3 introduced integrated support for attaching tags to posts. Many older WordPress themes do not have this option integrated.

  7. Gravatar Comment Support

    With version 2.5 of WordPress came integrated support for Gravatars, centrally accessed avatars that can be displayed accross all Gravatar enabled blogs. Being a new addition to the core of WordPress most themes do not have support for this feature built in.

  8. Theme Creators footer links

    It’s important to know how the theme creator has licensed thier work and what they will and will not allow you to do in terms of modifications and link removal. Nearly all free themes will require that the footer credit links be left exactly as they are in the original theme release. This sometimes includes sponsored links. There are two possible locations in the theme files that the licensing information and limitations can usually be found, either in a readme.txt file, or in the first parte of the style.css file. Be sure to review this information so that you will not find yourself in copyright violation with the theme author.

  9. Funny business in the code

    Most theme authors are honest people sharing their work either for publicity or simply out of generosity. It is always a good idea, though, to check through the code of each file in the theme to catch any potential spam that might be hidden in the code. It probably won’t display on your site but the code could be lurking in the corners. If such code does exist on your site you could, quickly, find yourself banned from search engine results.