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'm trying to create a simple theme options page that uses widgets to change the layout of content on the front page.

I started off by using meta boxes not realizing that the position is based on the user.

Any nudge in the right direction would be awesome.

EDIT TO ADD MORE DETAIL: I'm trying to duplicate the functionality of widgets. What I would like is to have an options page that has a set number of items that can be rearranged (sorted) in any order. These items represent content like a text block or an ad. I then want to take the order of the items and display their content on the front page of the site. I want this to be a global setting so if any user changes the order it shows the same order for anyone looking at the site.

PROGRESS: I've created an array and put my initial order of things and used update_option to store the data. I can sort the items but I don't know how to save this order.

if(get_option('content_boxes') == false) {
    $content_boxes = array(
        array('title' => 'Downloads', 'id' => 'k2-settings-downloads', 'content' => 'k2_settings_downloads', 'order' => '1'),
        array('title' => 'Sites', 'id' => 'k2-settings-sites', 'content' => 'k2_settings_sites', 'order' => '2'),
        array('title' => 'Tips', 'id' => 'k2-settings-tips', 'content' => 'k2_settings_tips', 'order' => '3'),
        array('title' => 'Live', 'id' => 'k2-settings-live', 'content' => 'k2_settings_live', 'order' => '4'),
        array('title' => 'Ad - 728x90', 'id' => 'k2-settings-ad-one', 'content' => 'k2_settings_ad_one', 'order' => '5'),
        array('title' => 'Ad - 728x90', 'id' => 'k2-settings-ad-two', 'content' => 'k2_settings_ad_two', 'order' => '6')
    update_option('content_boxes', $content_boxes);

$content_boxes = get_option('content_boxes');
if(!is_array($content_boxes)) {
    $content_boxes = array();

foreach ($content_boxes as $boxes) {
    $order[] = $boxes['order']; 
array_multisort($order, SORT_NUMERIC, $content_boxes);


<form method="post" action="">
        <?php settings_fields('content_boxes_group'); ?>
        <div class="metabox-holder">
            <div id="advanced-sortables" class="meta-box-sortables ui-sortable">
                <?php foreach($content_boxes as $boxes) {?>
                    <div id="<?php echo $boxes['id']; ?>" class="postbox closed">
                        <div class="handlediv" title="Click to toggle"><br></div><h3 class="hndle"><span><?php echo $boxes['title']; ?></span></h3>
                        <div class="inside">
                            <?php echo $boxes['content']; ?>
                <?php } ?>
        <div class="submit">
            <input type="submit" class="button-primary" value="Save Order">
share|improve this question
Check out advancedcustomfields.com. It may help with this type of functionality. – Bryan Monzon May 16 '13 at 0:06
You want your meta-boxes fixed in place? Or, perhaps a better question would be "would that solve the problem?" – s_ha_dum May 16 '13 at 0:08
@s_ha_dum I'm basically trying to duplicate the functionality of the widget page but with a set amount of widgets that can be rearranged into any order and the front page of the site would show the content in that order. – kel May 16 '13 at 15:07
Please edit your question to be more clear and include more detail. Why is "the position based on the user" a problem? You want the box positions to be global-- the same for all users? – s_ha_dum May 16 '13 at 15:10
@s_ha_dum I've updated the post. – kel May 16 '13 at 15:46

Your Answer


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

Browse other questions tagged or ask your own question.