Есть плагин на WordPress, который с помощью шорткода выводит нужные данные. Как ограничить данные до 10 или таблице до 10 ячеек?
<?php
function game_plugin_function()
{
global $wpdb;
$table_group = $wpdb->prefix . "bp_groups"; // group
$table_members = $wpdb->prefix . "bp_groups_members"; // group members
$table_matauser = $wpdb->prefix . "usermeta"; // user meta
$groups_array = array();
$sql_groups = $wpdb->get_results("SELECT * FROM $table_group");
foreach($sql_groups as $sql_groups_new)
{
$a_group_id = $sql_groups_new->id;
$a_group_name = $sql_groups_new->name;
$sql_members = $wpdb->get_results("SELECT * FROM $table_members where group_id = '$a_group_id'");
foreach($sql_members as $sql_members_new)
{
$a_member_id = $sql_members_new->user_id;
$sql_pointer = $wpdb->get_results("SELECT meta_value FROM $table_matauser where user_id = '$a_member_id' AND meta_key = '_gamipress_star_points' ");
foreach($sql_pointer as $sql_pointer_new)
{
$a_groups_points = $sql_pointer_new->meta_value;
$groups_array[$a_group_name] += $a_groups_points;
}
}
}
array_filter($groups_array);
arsort($groups_array);
$icount_rank = 0;
?>
<table>
<tr>
<th>
Rank
</th>
<th>
Group
</th>
<th>
Points
</th>
</tr>
<?php
foreach($groups_array as $groups_array_title => $groups_array_points)
{
$icount_rank++;
echo '<tr>';
echo '<td>';
echo $icount_rank;
echo '</td>';
echo '<td>';
echo $groups_array_title;
echo '</td>';
echo '<td>';
echo $groups_array_points;
echo '</td>';
echo '</tr>';
}
?>
</table>
<?php
}
?>