Home Forums Front-end Issues Save select option on page refresh Reply To: Save select option on page refresh

  • For the first question, I’m not sure how the value is being submitted so I’m assuming that $_GET[‘press’] is an array of the selected values, if this assumption is incorrect then you’ll need to alter that part to match the submitted value.

    foreach ($years as $key => $value) {
      foreach ($value as $year) {
          <option value="<?php echo $year; ?>"<?php 
            if (in_array($year, $_GET['press'])) {
              echo ' selected="selected";
            ?>><?php echo $year; ?></option>

    To show the posts for the selected years you need to create a pre_get_posts filter that alters the WP query. Check out some of these topics on using pre_get_posts