function voxel_display_author_followers($atts) {
global$wpdb;
$atts=shortcode_atts(
array(
'post_id'=>get_the_ID(),
),
$atts
);
$post_id=intval($atts['post_id']);
$table_name=$wpdb->prefix.'voxel_followers';
$author_id=$wpdb->get_var($wpdb->prepare(
"SELECT post_author FROM {$wpdb->prefix}posts WHERE ID = %d",
$post_id
));
if (!$author_id) {
return'No such post found.';
}
$follower_ids=$wpdb->get_col($wpdb->prepare(
"SELECT follower_id FROM$table_nameWHERE object_type = 'user' AND object_id = %d AND follower_type = 'user' ANDstatus=1ORDER BY follower_id DESCLIMIT6",
$author_id
));
if (empty($follower_ids)) {
return'';
}
$avatars=array_map(function ($user_id) {
returnget_avatar($user_id);
}, $follower_ids);
return'<div class="voxel-author-followers">'.implode('', $avatars) .'</div>';
}
add_shortcode('voxel_author_followers', 'voxel_display_author_followers');