Canned Spam
Coding

Stopping WordPress trackback spam without plugin


What is the most effective method for combating the trackback spam that inundates comment sections?

Altering the global Trackbacks configuration through the Dashboard -> Settings -> Discussion will exclusively modify the default behavior.

If you presently have posts or pages with trackbacks enabled, adjusting the default setting won’t affect the individual post-level settings.

To address this issue use the following filter to programmatically disapprove any trackback or pingback:

 add_filter('pre_comment_approved',function($approved,$comment){
		
	if( in_array($comment['comment_type'],array(
			
		'trackback',
		'pingback',
		
	))){
        
		$approved = false;
	}
		
	return $approved;
		
},999999,2);

Comments

Leave a Reply

About Rafasashi

Currently managing RECUWEB an IT Company providing cloud hosting and SaaS delivery model.

Related posts