'Authors',
'displayType' => 'cols',
'number' => '1',
'avSize' => '60'
);
}
// GET AUTHORS' IDS, NICE NAMES, AND DISPLAY NAMES (in post count 'descending' order)
$get_authors_by_id =
"SELECT ".$wpdb->users.".ID, ".$wpdb->users.".user_nicename ,".$wpdb->users.".display_name
FROM ".$wpdb->users.
" INNER JOIN ".$wpdb->posts." ON ".$wpdb->users.".ID=".$wpdb->posts.".post_author
WHERE post_status='publish' GROUP BY post_author ORDER BY count(post_author) DESC";
$author_ids = $wpdb->get_results($get_authors_by_id);
// FIND THE NECESSARY WIDTH OF THE DIV THAT SURROUNDS THE WIDGET
$width = ($authorGrid_options['avSize']+5)*$authorGrid_options['number'];
// SET DIV
echo '
';
}
function widget_authorGrid($args) {
global $wpdb;
// GET OPTIONS FROM DATABASE, IF NO OPTIONS EXIST, SET DEFAULTS
if(get_option('authorGrid_options')) {
$authorGrid_options = get_option('authorGrid_options');
} else {
$authorGrid_options = array( 'title' => 'Authors',
'displayType' => 'cols',
'number' => '1',
'avSize' => '60'
);
}
extract($args);
echo $before_widget;
echo $before_title;?> $authorGrid_title,
'displayType' => $authorGrid_displayType,
'number' => $authorGrid_number,
'avSize' => $authorGrid_avSize
);
// INSERT OPTIONS ARRAY INTO DATABASE
update_option( 'authorGrid_options', $authorGrid_options);
unset($_POST);
}
// DISPLAY WIDGET OPTIONS
// GET PRE-EXISTING OPTIONS FROM DATABASE
$authorGrid_options = get_option('authorGrid_options');
// FIND THE NUMBER OF AUTHORS WITH AT LEAST ONE PUBLISHED POST
$numberOfAuthors = $wpdb->get_results("select distinct post_author from $wpdb->posts where post_status='publish' and post_type='post'");
// SET TITLE
echo "Title: \n";
echo "";
echo "