Неправильно отображаемые поля в настройщике WordPress (создано три, но отображено одно) - PullRequest
0 голосов
/ 25 мая 2019

Я создал панель параметров в WordPress customizer.php:

// Add theme options panel.
    $wp_customize->add_panel(
     'anvitest-lite', array(
     'title'           => esc_html__( 'Theme Options', 'anvitest-lite' ),
     'priority' => 11,
        )
    );

Чем я добавил раздел:

$wp_customize->add_section(
     'title_section', array(
     'title' => esc_html__( 'Main Screen Section', 'anvitest-lite' ),
     'panel' => 'anvitest-lite',
        )
    );

До этого момента все работало нормально. Но в разделе мне нужно отобразить четыре поля с контактами (почта, адрес и номер телефона). Я создаю поля:

/**************************email_field****************************/
    $wp_customize->add_setting(
        'email_field', array(
            'default'           => ''
        )
    );
    $wp_customize->add_control(
        'title_section', array(
        'label'           => esc_html__( 'Enter E-mail', 'anvitest-lite' ),
        'section'         => 'title_section',
        'settings'        => 'email_field',
        'type'            => 'email',
        'description'     => esc_html__( 'Enter your mail in this field', 'anvitest-lite' ),
        )
    );
    /**************************phone_field****************************/
    $wp_customize->add_setting(
        'phone_field', array(
            'default'           => ''
        )
    );
    $wp_customize->add_control(
        'title_section', array(
        'label'           => esc_html__( 'Enter Phone', 'anvitest-lite' ),
        'section'         => 'title_section',
        'settings'        => 'phone_field',
        'type'            => 'text',
        'description'     => esc_html__( 'Enter your phone in this field', 'anvitest-lite' ),
        )
    );
    /**************************adress_field****************************/
    $wp_customize->add_setting(
        'adress_field', array(
            'default'           => ''
        )
    );
    $wp_customize->add_control(
        'title_section', array(
        'label'           => esc_html__( 'Enter Adress', 'anvitest-lite' ),
        'section'         => 'title_section',
        'settings'        => 'adress_field',
        'type'            => 'text',
        'description'     => esc_html__( 'Enter your adress in this field', 'anvitest-lite' ),
        )
    );

Но из этого в настройщике отображается только поле для ввода адреса электронной почты. см. экран: http://prntscr.com/nt891d. Пожалуйста, скажите мне, что я делаю не так. Спасибо!

1 Ответ

0 голосов
/ 26 мая 2019

Я нашел решение. Вот код:

 $wp_customize->add_panel(
        'anvitest-lite',[
            'title'           => esc_html__( 'Theme Options', 'anvitest-lite' ),
            'priority' => 11,
        ]
    );

    $wp_customize->add_section(
        'title_section', [
            'title' => esc_html__( 'Main Screen Section', 'anvitest-lite' ),
            'panel' => 'anvitest-lite',
            'priority'  => 200,   
        ]
    );


    $wp_customize->add_setting(
        'email_field', array(
            'default'           => ''
        )
    );
    $wp_customize->add_control(
        'email_field', array(
            'section'         => 'title_section',
            'type'            => 'email',
            'description'     => esc_html__( 'Enter your mail in this field', 'anvitest-lite' ),
        )
    );
    /**************************phone_field****************************/
    $wp_customize->add_setting(
        'phone_field', array(
            'default'           => ''
        )
    );
    $wp_customize->add_control(
        'phone_field', array(
            'label'           => esc_html__( 'Enter Phone', 'anvitest-lite' ),
            'section'         => 'title_section',
            'type'            => 'text',
            'description'     => esc_html__( 'Enter your phone in this field', 'anvitest-lite' ),
        )
    );
    /**************************adress_field****************************/
    $wp_customize->add_setting(
        'adress_field', array(
            'default'           => ''
        )
    );
    $wp_customize->add_control(
        'adress_field', array(
            'label'           => esc_html__( 'Enter Adress', 'anvitest-lite' ),
            'section'         => 'title_section',
            'type'            => 'text',
            'description'     => esc_html__( 'Enter your adress in this field', 'anvitest-lite' ),
        )
    );
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...