I’m currently developing a games database for my wordpress site and one of the custom functions is entering a review score for a game, we have a 1-10 based rating system but I wish to add another option to this loop “No Review”, how can I do this?
<select style="width: 100px" name="games_database_rating">
<?php // Generate all items of drop-down list
for ( $rating = 10; $rating >= 1; $rating -- ) {
?>
<option value="<?php echo $rating; ?>" <?php echo selected( $rating, $game_rating ); ?>>
<?php echo $rating; ?>/10 <?php } ?>
</select>
You just need to add a static
<option>
element before you start your loop.Now your
select
will start out with “No Rating”, and you can still choose a number. When you submit the form, just check for “none” or the number.