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 created an options page for my plugin where the user can specify image dimensions which will be saved for later use. So far the image dimensions are entered by the user in one input field like 200x200. To make it easier for the user I want to split that into two input fields with a x between them(one for x, one for y dimension).

My question is: How can I do that and still save those fields as one entry like 200x200? I mean, how can I tell wordpress that these two fields belong together?

So far my options page form looks like this:

<form method="post" action="options.php">
    <?php wp_nonce_field('update-options'); ?>
            Defined sizes so far:<br>
            <?php foreach($sizes as $size):?>
                <?php if($size!=""):?>
                    <div class="gpp_size_input"><input type="text" name="gpp_image_sizes[]" value="<?php echo $size;?>" readonly="readonly"><span class="gpp_minus">-</span></div>
            <div class="gpp_size_input"><input type="text" name="gpp_image_sizes[]"><span class="gpp_plus">+</span></div>
            <input type="hidden" name="action" value="update" />
            <input type="hidden" name="page_options" value="gpp_image_sizes" />
            <input type="submit" value="Save" />

As you can see, the already defined sizes get listed and can be removed(that's js in the background) and a new input is created if the user wants to define a new size and save it.

share|improve this question
up vote 0 down vote accepted

Name one field gpp_image_sizes[width] and the second gpp_image_sizes[height]. You will get an array in your save callback:

$_POST = array (
    'gpp_image_sizes' => array (
        'width'  => 100, // some number
        'height' => 100, // some number
share|improve this answer

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.