Security, SEO

The Problem of Spam Comments in WordPress

August 17, 2024
|
Read Time: Estimating...
By Chris Ard

In this article:

Share this on:

The WordPress Commenting System

Spam comments are a persistent issue for many WordPress site owners. Not only do they clutter up your site, but they can also affect your site’s SEO and overall user experience. Despite this, comments are enabled by default in WordPress, which isn’t always necessary for many users who don’t even utilize the comment section.

For many website owners, especially those running business sites or portfolios, the comment section is often redundant. These sites focus on showcasing services or products rather than engaging in discussions. Enabling comments by default leads to unnecessary spam management and moderation tasks.

Pingbacks and Trackbacks: Enabled by Default

In addition to comments, WordPress also enables pingbacks, trackbacks, and even in some cases image attachments by default. These features allow other blogs to notify you when they link to your content. While this might sound useful in theory, it often results in more spammy notifications than genuine interactions.

chatbot

What Are Pingbacks and Trackbacks?

  • Pingbacks: When another blog links to one of your posts, a pingback is automatically sent. This acts as a form of acknowledgement or backlink.
  • Trackbacks: These are manual notifications sent when someone mentions your blog post on their site.

Pingbacks and Trackbacks were designed to foster a sense of community among bloggers but have unfortunately become tools for spammers.

Resources:

Why Are They Problematic?

  1. Spammy Notifications: Most pingback and trackback notifications are spammy in nature. They often come from low-quality sites looking to gain backlinks.
  2. Resource Drain: Processing these notifications can consume server resources, slowing down your site.
  3. SEO Impact: Spam links can negatively affect your site’s SEO if not managed properly.

Image Attachments: A Hidden Culprit

Another overlooked issue is that image attachments can also have comments enabled by default in WordPress. While turning comments off for new posts will solve this in the future, it does not do it retroactively, leaving the same problem as pingbacks where you have to manually edit each image (which can be even more time consuming!).

Why Is This Objectively Bad?

  1. Unwanted Spam: Spam bots can target image attachments just as easily as posts or pages, leading to an influx of unwanted comments.
  2. SEO Issues: Similar to posts, spammy comments on image attachments can negatively impact SEO.
  3. User Experience: Users might stumble upon these attachments with spammy comments, detracting from the overall quality of your site.

Deactivating Comments, Pingbacks, and Trackbacks in WordPress

To maintain a clean site free from spammy clutter:

  1. Disable Comments on New Posts: You can turn off comments for all new posts via the Settings > Discussion menu.
  2. Disable Pingbacks/Trackbacks: Similarly, you can disable pingbacks/trackbacks under the same settings.
  3. Bulk Edit Existing Posts: There isn’t an option by default in WordPress to do this, so it can be quite time consuming to do each of these in bulk on larger sites.

Deactivating Comments Programmatically

The following can typically be added to your functions.php file or custom PHP snippet area. It is worth noting that this programmatically disables the commenting system, but does not alter the database values for your content. As such this change can easily be reverted by removing the code, whereas an SQL query cannot be undone unless you restore it from a backup.

1. Disable comments for attachments and/or posts (or other post types):

add_filter('comments_open', 'as_disable_comments'], 20, 2);

function as_disable_comments($open, $post_id) {
    $postType = get_post_type($post_id);
    $postValue = ['post', 'attachment'];

    if (in_array($postType, $postValue)) {
        return false;
    } else return $open; // return default status
}

2. Remove backend interface for comments and trackbacks (including other post types):

add_action('admin_init', 'as_disable_comments_post_types_support');

function as_disable_comments_post_types_support() {
    $post_types = ['post', 'page'];

    // remove attachment comment support regardless
    remove_post_type_support('attachment', 'comments');
    remove_post_type_support('attachment', 'trackbacks');

    foreach ($post_types as $post_type) {
        if (post_type_supports($post_type, 'comments')) {
            remove_post_type_support($post_type, 'comments');
            remove_post_type_support($post_type, 'trackbacks');
        }
    }
}

Dynamically Change All Database Values Using SQL

You can also use SQL statements to achieve this directly in your WordPress database. This approach can be faster, especially if you have a large number of posts and attachments, but it is a permanent change, so be sure to backup your database before proceeding. This can be used in conjunction with the above so future comments, pingbacks/trackbacks are not allowed, but also the statuses are actually updated across all posts and media types.

Our tables below are using a standard wp_ reference, but if you are using a custom prefix, make sure to update as needed, e.g. wp_q48f_

Below are the SQL queries to:

  1. Change the comment status to ‘closed’ for all posts.
  2. Change the comment status to ‘closed’ for all attachments.

1. Change Comment Status for Posts.

UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed' WHERE post_type = 'post';

2. Change Comment Status for Attachments

UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed' WHERE post_type = 'attachment';

The One-Click Solution with Our Plugin

Manually updating settings for each content type can be tedious and time-consuming—this is where our plugin shines:

  1. One-Click Deactivation: Our plugin allows users to disable all commenting features with a single click.
  2. Retroactive Changes: It works retroactively on all existing posts/pages so you don’t have to manually edit each one.
  3. User-Friendly Interface: The plugin’s user-friendly interface ensures that even non-technical users can manage their site’s commenting settings easily.

Spam management doesn’t have to be a headache! With our plugin’s robust features and user-friendly interface, maintaining a clean site is easier than ever before.

Would you like more detailed information on any specific feature or additional tips on managing your WordPress site? Get in touch with us today to book a consultation and get a website audit to find gaps like this in your current WordPress setup.

Share this on:
(This article was last updated on August 29, 2024)

Ready to get started?

Transform your online business with cutting-edge web solutions that promise speed, reliability, and security.

Experience bespoke website design, premium hosting, and stress-free maintenance — all expertly crafted to your needs. Reach out now for a tailor-made digital experience that sets you apart!

You selected

Awesome! We just need a few details first ...

Help us get to know you and your requirements with some basic info.