Exclude admin di recent comments widget WordPress

Cara menghilangkan komentar administrator (exclude admin) di recent comments widget blog WordPress tanpa menggunakan plugin.

Exclude Admin Recent Comments Widget

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.


Author: Jevuska

Rachmanuddin Chair Yahya a.k.a Jevuska is the founder of Jevuska.Com, a qualified web about offering medical articles, blogging, tips, and tutorial of WordPress. Having written for Jevuska since 2007.

Leave a Reply

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

Use tag [php] to add code, e.g. [php]<?php echo $var; ?>[/php]