下面是我自己对这个问题的回答。如有任何建设性意见,我将不胜感激。
add_shortcode( \'group_members\', \'group_members_shortcode_handler\' );
function group_members_shortcode_handler ( $atts, $content = null ) {
global $wpdb;
$querystr = "SELECT * FROM wp_groups_user_group";
$users = $wpdb->get_results($querystr, OBJECT);
$output=\'\';
foreach ($users as $user) {
if($user->group_id == $atts[\'group_id\']){
$firstName = esc_html(get_user_meta($user->user_id, \'first_name\', true));
$lastName = esc_html(get_user_meta($user->user_id, \'last_name\', true));
$output .= \'<li>\' . $firstName . \' \' . $lastName . \' - \' . esc_html(get_user_meta($user->user_id, \'teaching_position\', true)) . \'</li>\' . PHP_EOL;
}
}
return $output;
}