Skip to content

Disabling Comments on a WordPress Demo Site

As a WordPress theme author I have to set up demo sites for my themes. I tend to set up the site – and then leave it to sit there. The other day I was going through the demo for Opti and realised I hadn’t enabled a spam blocking plugin, and so there were 12k unmoderated comments. Not ideal, so I set up a really simple plugin that stops all comments dead. This means that the comment doesn’t need to go through Akismet or any other spam blocking service. It stops before it hits the database.

And it was super simple.

< ?php

function bm_ptd_comments_disabled() {
    echo 'sorry - comments are disabled on the demo site.';
    die();
}

add_filter( 'preprocess_comment', 'bm_ptd_comments_disabled' );

Ben View All

Ben is a lifelong Nintendo fan who also likes to build websites, and develop games. He also buys way too much Lego.

One thought on “Disabling Comments on a WordPress Demo Site Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *