Exclude Admin Recent Comments Widget

Exclude admin di recent comments widget WordPress

Bagaimana cara supaya administrator atau owner yang komentar di blognya sendiri tidak muncul (exclude) di recent comments widget blog WordPress?. Tanpa harus menggunakan plugin tambahan, Anda bisa memasang function berikut di file functions.php theme WordPress Anda.

add_filter('widget_comments_args', '_jv_filter_recent_comments_widget');

function _jv_filter_recent_comments_widget(){
	// get data from database table wp_options with option_name 'widget_recent-comments'
	$instance = array_shift(get_option('widget_recent-comments'));
	$number = absint($instance['number']);
	$args = array(
		'number'         => $number,
		'status'         => 'approve',
		'post_status'    => 'publish',
		'author__not_in' => 1, // '1' is user id of administrator/owner
        );
	return $args;
}

Save pekerjaan Anda and see the result.

Jadi, kecuali owner blog, para pengunjung lain yang komentar di blog Anda tetap ada di recent comments (komentar terbaru) widget.

Leave a Reply

*

*