Title: trying to save multiple select fields using update_options
Last modified: August 21, 2016

---

# trying to save multiple select fields using update_options

 *  Resolved [Derek Smart](https://wordpress.org/support/users/dsmartdesign/)
 * (@dsmartdesign)
 * [12 years ago](https://wordpress.org/support/topic/trying-to-save-multiple-select-fields-using-update_options/)
 * Displaying a list of all pages in a select field. I want multiple pages to be
   able to be selected. I have been reading and reading, but still don’t seem to
   get how this works.
 * I can get the selected fields to echo out, but they don’t seem to be saving, 
   i.e. when page is reloaded the selections are gone.
 * the fields:
 *     ```
       <select id="exclude_page_from_cookies" name="exclude_page_from_cookies[]" multiple="multiple">
       			<?php
   
       			$pages = get_pages();
       			foreach ( $pages as $page ) {
       				$title = $page->post_title;
       				$id    = $page->id;
       				?>
   
       				<option id="<?php echo $id; ?>" value="<?php echo $title ?>" <?php selected( $title ); ?> >
       					<?php echo $title;?>
       				</option>
       			<?php
       			}
       			?>
       		</select>
       ```
   
 * The save
 *     ```
       if ( isset( $_POST['exclude_page_from_cookies'] ) ) {
       			foreach( $_POST['exclude_page_from_cookies'] as $exclude_page ) {
       				echo $exclude_page;
       				update_option( 'exclude_page_from_cookies', $exclude_page ) ;
       			}
       		}
       ```
   
 * Thank you all in advance.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Derek Smart](https://wordpress.org/support/users/dsmartdesign/)
 * (@dsmartdesign)
 * [12 years ago](https://wordpress.org/support/topic/trying-to-save-multiple-select-fields-using-update_options/#post-4925636)
 * moved to [http://wordpress.org/support/topic/trying-to-save-multiple-select-fields-using-update_options-1?replies=1](http://wordpress.org/support/topic/trying-to-save-multiple-select-fields-using-update_options-1?replies=1)

Viewing 1 replies (of 1 total)

The topic ‘trying to save multiple select fields using update_options’ is closed
to new replies.

## Tags

 * [html](https://wordpress.org/support/topic-tag/html/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [select](https://wordpress.org/support/topic-tag/select/)
 * [update_options](https://wordpress.org/support/topic-tag/update_options/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 1 participant
 * Last reply from: [Derek Smart](https://wordpress.org/support/users/dsmartdesign/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/trying-to-save-multiple-select-fields-using-update_options/#post-4925636)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
