WordPress - Kommentare zu Anhängen deaktivieren

WordPress - Kommentare zu Anhängen deaktivieren

Nach dem Stoppen und Bereinigen derWordPress pingback and trackback spams haben diese Spammer ihre Strategie geändert, um Kommentare und Trackbacks auf die Post-Anhänge zu spammen.

Lösung

1.1 Stop commenting on new and existing attachment. Fügen Sie unten das PHP-Skript infunction.phpdes Themas hinzu

${theme_folder}/function.php

//disable comments on attachment
function filter_media_comment_status( $open, $post_id ) {

    $post = get_post( $post_id );
    if( $post->post_type == 'attachment' ) {
        return false;
    }
    return $open;

}
add_filter('comments_open', 'filter_media_comment_status', 10 , 2 );

1.2 Update existing attachments, in wp_posts table, update post attachment ping_status and comment_status to closed

phpMyAdmin- oder MySQL-Konsolen

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

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

1.3 Delete the existing comment spam. Die Kommentare im Anhang werden als Kommentare vontrackbackangegeben.

DELETE FROM  `wp_comments` WHERE  `comment_type` =  'trackback'

Note
WordPress sollte wirklich in Betracht ziehen, die Pingback- und Trackback-Funktionen standardmäßig zu deaktivieren. Es zieht viele Spammer an und erhöht den Wert der WordPress-Plattform. Übrigens, wer benutzt Trackback?