Incorporating an Akismet Counter Into a WordPress Theme

Akismet is, by far, the most popular anti-spam plug-in for WordPress. (It comes bundled with the download, so that gets it market share. But, it’s also very, very good.) It comes with a counter that can be put into a WordPress theme. It’s attractive, but its light blue color may not integrate well into a given theme.

I went digging around in the source code, and found the line that actually pulls the count from the database. Using this parameter, I was able to integrate a spam count into the sidebar that has a look consistent with the rest of the site.

Here’s the code that’s in use on the theme on this site.

1
2
3
4
5
6
7
8
<li id="spamstats">
	<h2><?php _e('Akismet-Eaten Spam:'); ?></h2>
	<ul>
		<li><a href="http://akismet.com"><?php
			echo(number_format(get_option("akismet_spam_count"))); ?>
			and counting...</a></li>
	</ul>
</li>

Of course, line 5 is the important one – that’s how to get the number, formatted for whatever locale the server is set up for. (On my personal blog, the number is up over 1,400!)

5 Comments »

  1. hggylodoyo said,

    February 4, 2008 at 12:58 pm

    Hello! Good Site! Thanks you! uvjnwgsnueyva

  2. Doctor Informática » Insertar Akismet counter en mi plantilla said,

    March 29, 2008 at 1:10 pm

    [...] un código para integrar el contador de spams del plugin Akismet para Wordpress en mi plantilla, este lo he visto en esta web Lo he modificado a mi manera y para mi plantilla tenemos esto: 1 2 <ul><li><img [...]

  3. Skinning the Akismet Counter | The Danosphere. said,

    May 25, 2008 at 1:08 pm

    [...] How to Change the Skin / Theme of the Akismet Spam Counter [...]

  4. 68.39.6.17:2479 said,

    March 17, 2010 at 4:07 pm

    This blog had been a nice read! I could not have stated things better myself.

  5. Laura Brisbane said,

    May 24, 2010 at 5:14 pm

    Cool, thanks for that! Is there any way to not have the spam count shown on the page though?

RSS feed for comments on this post · TrackBack URL

Leave a Comment