WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two forms. One for adding, one for deleting option values. Deleting and adding works, but I have to manualy reload page to see changes in select part. How to make theme apper after submit?

    <form method="post" action="">
      <input type="text" name="add" class="foo-add" />
      <input type="submit" value="Add" />

    <form method="post" action="" name="foo-delete">
        <select multiple="multiple" name="foo-values">
        $foo_values = unserialize( get_option( 'foo_values' ));
        $foo_values_keys = array_keys($foo_values);
        $i = 0;
        foreach($foo_values as $foo): ?>
          <option value="foo_<?php echo $foo_values_keys[$i]; ?>"><?php echo $foo[0]; ?></option>
          <?php $i++; ?>
        <?php endforeach; ?>
        <input type="submit" value="Delete" />
      if($_POST) {
        if(isset($_POST['foo-values'])) {
          preg_match('/\d/', $_POST['foo-values'], $foo_id);
          update_option( 'foo_values', serialize($foo_values));
        } else {
          array_push($foo_values, $_POST['foo-add']);
          update_option( 'foo_values', serialize($foo_values));
share|improve this question
up vote 0 down vote accepted

Put the PHP code that handles data at the very top of the page before you print that data.

share|improve this answer
I tried header reload but wordpress dosen't allow for this and rise an error – stamp Oct 16 '12 at 11:39
Second method works, thx – stamp Oct 16 '12 at 11:51
Yes, silly me. Header redirects fail if output precedes them. Edited the post to reflect this. Glad the other way solved it. – user5028 Oct 17 '12 at 0:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.