Skip to content

Commit

Permalink
Added count
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoensing committed Jan 4, 2024
1 parent 91fe7ae commit 71ab9d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/game-table/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function render_game_table($attributes)

// Add table headers
$html .= '<thead><tr><th class="th-sort-desc">' . __( 'Rating', 'game-review-block' ) . '</th><th class="th-sort-desc">' . __( 'Game title', 'game-review-block' ) . '</th><th class="th-sort-desc">' . __( 'Review published', 'game-review-block' ) . '</th></tr></thead><tbody>';

$count = 0;
// Loop through the posts
while ($the_query->have_posts()) :
$the_query->the_post();
Expand All @@ -52,11 +52,14 @@ function render_game_table($attributes)

// Check if game name is not empty and current rating is greater than 0
if (($game != '') and $current_rating > 0) {
$count++;
// Add a row to the table for each game
$html .= "<tr><td>" . $current_rating . "/10</td><td><a href='" . $url . "'>" . $game . "</a></td><td data-time=" . $publish_date_unix . ">" . $publish_date . "</td></tr>";
}
endwhile;

$html .= "\n</ul><!-- Count: ". $count . " -->\n";

// Close the table tags
$html .= "</tbody></table>";

Expand Down

0 comments on commit 71ab9d8

Please sign in to comment.