Custom fields wp_customizer

0

Good afternoon, I have a template in html5, and I want to adapt it with wordpress creating custom fields in the customizer, I have a problem, I have created the main panel which I want to host the sections of my page, and this panel will add a section, but I could not add another one, the code I have is

// PANEL PRINCIPAL
    $wp_customize->add_panel( 'davidvpino_theme_options', array(
        'title'       => __( 'Opciones de Tema DavidVPino', 'davidvpino' ),
        'capability'  => 'edit_theme_options',
        'description' => __( 'Administracion de Secciones', 'davidvpino' ),
        'priority'    => 1,
    ) );

    // FIN DE   DEL PANEL PRINCIPAL

    // SECCIONES DEL PANEL PRINCIPAL

    $wp_customize->add_section( 'davidvpino_theme_home', array(
        'title'       => __( 'Seccion Inicio', 'davidvpino' ),
        'capability'  => 'edit_theme_options',
        'panel'             => 'davidvpino_theme_options',
        'description' => __( 'Imagen y texto de la sección Inicio', 'davidvpino' ),
        'priority'    => 10,
    ) );

    $wp_customize->add_section( 'davidvpino_theme_about', array(
        'title'       => __( 'Seccion Acerca de', 'davidvpino' ),
        'capability'  => 'edit_theme_options',
        'panel'             => 'davidvpino_theme_options',
        'description' => __( 'Imagen y texto de la sección Acerca de', 'davidvpino' ),
        'priority'    => 20,
    ) );
    // FIN DE SECCIONES DEL PANEL PRINCIPAL

the davidvpino_theme_home section appears in the panel that you create but davidvpino_theme_about does not appear as shown in the image

Someone could tell me exactly what is due, if you should create another array-type function to add several sections to a panel.

    
asked by David Vásquez Pino 12.06.2017 в 21:26
source

1 answer

0

The first thing is that I recommend using Advanced Custom Fields (ACF) , it is a plugin that solves many hours of Wordpress development.

I have been using it for a long time and it greatly facilitates this kind of thing.

If you could read the Wordpress codex on customize_register

You have to run everything inside the hook customize_register , here I do not see it but I guess you'll be inside that function.

It may not be showing up because it has no content to show, the first one could appear so that it does not appear "empty".

I've tried your code and it works, try to add some content to see if you have a bug:

$wp_customize->add_section(
    'prueba',
    [
        'title'    => __('Prueba', 'davidvpino'),
        'priority' => 10,
    ]
);

$wp_customize->add_control(
    'slider_display',
    [
        'type'           => 'checkbox',
        'label'          => __('Checkbox prueba.', 'davidvpino'),
        'section'        => 'prueba',
        'priority'       => 10,
    ]
);

If not, you tell me and we look for possible errors.

It would also be nice to know the Wordpress and PHP version. In my case Wordpress 4.8 and PHP 7.0.18

    
answered by 13.06.2017 в 13:44