• In the child theme I have developed I’m trying to add an option to the select blog_layout_view (you can find it in Blog settings >Blog Index Settings under Blog Layout section. I’m talking about the one generated by

    $wp_customize->add_control(
    blog_layout_view’, array(
    label’ => esc_html__( ‘Blog Layout’, ‘shapely’ ),
    description’ => esc_html__( ‘Choose how you want to display posts in grid’, ‘shapely’ ),
    ‘section’ => ‘shapely_blog_section’,
    type’ => ‘select’,
    ‘choices’ => array(
    ‘grid’ => esc_html__( ‘grid only’, ‘shapely’ ),
    ‘large_image_grid’ => esc_html__( ‘Large Image and Grid’, ‘shapely’ ),
    ‘large_image’ => esc_html__( ‘Large Images’, ‘shapely’ ),
    ),
    )
    );

    I thought I could do this by editing the function.php file of my child theme by adding in it

    function add_new_option_to_select( $choices ) {
    $choices[‘new_option’] = ‘New option’;
    return $choices;
    }
    add_filter( ‘customize_option_shapely_blog_section_layout_view_choices’, ‘add_new_option_to_select’, 999);

    but it doesn’t work… what should be the correct procedure to do this?

Viewing 1 replies (of 1 total)
  • Thread Starter mikymartin

    (@mikymartin)

    Solved!

    in my functions.php

    function projects_customize_register( $wp_customize ) {
        $wp_customize->add_setting(
            'blog_layout_view', array(
                'default'           => 'grid',
                'sanitize_callback' => 'wp_kses_stripslashes',
            )
        );
    
        $wp_customize->add_control(
            'blog_layout_view', array(
                'label'       => esc_html__( 'Blog Layout', 'shapely' ),
                'description' => esc_html__( 'Choose how you want to display posts in grid', 'shapely' ),
                'section'     => 'shapely_blog_section',
                'type'        => 'select',
                'choices'     => array(
                    'grid'             => esc_html__( 'Grid only', 'shapely' ),
                    'large_image_grid' => esc_html__( 'Large Image and Grid', 'shapely' ),
                    'large_image'      => esc_html__( 'Large Images', 'shapely' ),
                    'new_option'    => esc_html__( 'New Option', 'shapely' ), // Aggiungi la nuova opzione qui
                ),
            )
        );
    }
    add_action( 'customize_register', 'projects_customize_register', 11 );
    
Viewing 1 replies (of 1 total)
  • The topic ‘Customizer, add option, child theme’ is closed to new replies.