Title: Problem sorting theme_mod array
Last modified: August 21, 2016

---

# Problem sorting theme_mod array

 *  [winnewoerp](https://wordpress.org/support/users/joschi81/)
 * (@joschi81)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/problem-sorting-theme_mod-array/)
 * Hi there,
 * I’m working on a thema with an extended customization panel. I’m creating a social
   media section, but the array of social media networks seen below is not being
   sorted correctly.
 * Maybe it’s because I didn’t put the values alphabetically first and now the old
   order is still being saved in some “hidden corner” of the system… When I do a`
   print_r()` of the sorted array, it’s being sorted correctly, but the output in
   the customization panel is not correct.
 * Any idea? Thank you!
 *     ```
       function mytheme_customize_extend( $wp_customize ) {
       	/* Social Media customizer section */
       	$wp_customize->add_section( 'mytheme_section_socialmedia' , array(
       		'title'      => __( 'Social Media Links', 'mytheme' ),
       		'priority'   => 40,
       	));
       	$social_media_settings = array('aim','behance','digg','dribbble','ember','evernote','facebook','flickr','forrst','github','googleplus','lastfm','linkedin','paypal','rss','sharethis','skype','soundcloud','tumblr','twitter','vimeo','wordpress','yahoo','youtube','zerply');
       	sort($social_media_settings);
       	foreach($social_media_settings as $key => $setting) {
       		$setting_shortname = 'link_'.$setting;
       		$setting_output = ucfirst($setting);
       		$setting_name = 'mytheme_theme_options['.$setting_shortname.']';
       		$wp_customize->add_setting($setting_name, array(
       			'default'           => '',
       			'capability'        => 'edit_theme_options',
       		));
       		$wp_customize->add_control( new WP_Customize_Control($wp_customize, $setting_shortname, array(
       			'label'    => sprintf(__( 'Link to %s page', 'mytheme' ).' '.$key, $setting_output),
       			'section'  => 'mytheme_section_socialmedia',
       			'settings' => $setting_name,
       		)));
       	}
   
       }
       add_action( 'customize_register', 'mytheme_customize_extend' );
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [prison47](https://wordpress.org/support/users/prison47/)
 * (@prison47)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/problem-sorting-theme_mod-array/#post-4259343)
 * Hello, Did you solved this problem? I have the same problem 🙁
 *  [prison47](https://wordpress.org/support/users/prison47/)
 * (@prison47)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/problem-sorting-theme_mod-array/#post-4259344)
 * Oh, I found the solution. You should set the priority: ‘priority’=>’1’
 *  Thread Starter [winnewoerp](https://wordpress.org/support/users/joschi81/)
 * (@joschi81)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/problem-sorting-theme_mod-array/#post-4259347)
 * Hi prison47,
 * isn’t the priority setting only to sort the output order of the customization
   menu? I don’t see how it could solve my problem mentioned above.
 * Regards
    joschi81

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problem sorting theme_mod array’ is closed to new replies.

## Tags

 * [add_setting](https://wordpress.org/support/topic-tag/add_setting/)
 * [array](https://wordpress.org/support/topic-tag/array/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * 3 replies
 * 2 participants
 * Last reply from: [winnewoerp](https://wordpress.org/support/users/joschi81/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/problem-sorting-theme_mod-array/#post-4259347)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
