"Spam Blocked by Akismet" Counter Shortcode
Adds a [wpide_akismet_count] shortcode that shows how many spam comments Akismet has blocked on your site, a small trust signal for footers and contact pages.
Opens WPIDE on
Code
add_shortcode( 'wpide_akismet_count', function ( $atts ) {
if ( ! class_exists( 'Akismet' ) ) {
return '';
}
$atts = shortcode_atts( array( 'text' => '%s spam comments blocked by Akismet' ), $atts, 'wpide_akismet_count' );
$count = (int) get_option( 'akismet_spam_count', 0 );
if ( ! $count ) {
return '';
}
return '<span class="wpide-akismet-count">' . esc_html( sprintf( $atts['text'], number_format_i18n( $count ) ) ) . '</span>';
} );
Notes
Use [wpide_akismet_count text="%s spam comments blocked"]; %s becomes the number.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.