Support

Account

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>
        <?php 
      }
    }
    

    To show the posts for the selected years you need to create a pre_get_posts filter that alters the WP query. https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts. Check out some of these topics on using pre_get_posts https://support.advancedcustomfields.com/forums/search?bbp_search=pre_get_posts