Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add custom fields to the wordpress theme customizer for the theme that I'm creating.

$wp_customize->add_section(
      'sometheme_theme_customization_section',
      array(
          'title' => __('Settings', 'sometheme'),
          'description' => 'Custom settings for the sometheme theme',
          'priority' => 35,
      )
  );

  $wp_customize->add_setting(
    'sometheme_headline',
    array(
        'default' => '',
        'sanitize_callback' => 'sometheme_sanitize_text'
    )
  );

  $wp_customize->add_control(
    'sometheme_headline',
    array(
        'label' => __('Headline', 'sometheme'),
        'section' => 'sometheme_theme_customization_section',
        'type' => 'text',
    )
  );

  $wp_customize->add_setting(
    'sometheme_tagline',
    array(
      'default' => '',
      'sanitize_callback' => 'sometheme_sanitize_text'
    )
  );

  $wp_customize->add_control(
    'sometheme_tagline',
    array(
      'label' => __('Tagline', 'sometheme'),
      'section' => 'sometheme_theme_customization_section',
      'type' => 'text'
    )
  );

As you can see from the above code the headline is declared before the tagline. But for some reason the output always ends up like this:

enter image description here

Is this weird or have I miss something? Thanks in advance!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you need a specific ordering of the input fields, then add "priority" values to the controls in the add_control calls, same as you already have for the sections.

If you don't have a priority, then no particular order is guaranteed and you get whatever PHP happens to order your arrays as.

share|improve this answer

Your Answer

 
discard

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.