Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

user-selawat-jantina

// WP_User_Query arguments
$args = array(
	'exclude'        => array( 1 ),
	'number'         => '20',
	'offset'         => '1',
	'order'          => 'DESC',
	'orderby'        => 'display_name',
	'meta_query'     => array(
		'relation' => 'AND',
		array(
			'key'     => 'jumlah_selawat_user',
			'compare' => '=',
			'type'    => 'NUMERIC',
		),
		array(
			'key'     => 'gender',
			'value'   => 'Lelaki',
			'compare' => '=',
			'type'    => 'CHAR',
		),
	),
	'count_total'    => true,
	'fields'         => 'all',
);

// The User Query
$muhibbin_query = new WP_User_Query( $args );

// The User Loop
if ( ! empty( $muhibbin_query->results ) ) {
	foreach ( $muhibbin_query->results as $user ) {
		// do something
	}
} else {
	// no users found
}