• Hello

    i have create a customizer option for sidebar position. My question is how can i show sidebar position via url parameter like my sidebar position is selected as a right sidebar by default but if i change url like ‘mysite.com/?sidebar_position=left-sidebar’ i need to see sidebar to located on left side without changing option from customizer.

    Thanks

    Customizer option code is here

    // Sidebar Position
    
    $wp_customize->add_section( 'sidebar_position', array(
            'title' => __('Sidebbar Position', 'my_textdomain'),
            'description' => __('Select Sidebar Position.', 'my_textdomain'),
            'priority' => '900',
    	) );
    
    $wp_customize->add_setting( 'sidebar_position_option', array(
          'default' => 'right-sidebar',
          'type' => 'theme_mod',
    	'sanitize_callback' => 'candour_sanitize_sidebar_placement',
    ) );
    
    $wp_customize->add_control( 'sidebar_position_option', array(
        'label' => __('Display Sidebar on Left or Right', 'my_textdomain'),
        'section' => 'sidebar_position',
        'type' => 'radio',
        'choices' => array(
            'right-sidebar' => __('Right (Default)', 'my_textdomain'),
        	'left-sidebar' => __('Left', 'my_textdomain'),
            ),
    ) );
    
    function candour_sanitize_sidebar_placement( $input ) {
        $valid = array(
            'right-sidebar' => __('Right (Default)', 'my_textdomain'),
        	'left-sidebar' => __('Left','candour'),
        );
    
        if ( array_key_exists( $input, $valid ) ) {
            return $input;
        } else {
            return '';
        }
    }

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How can i change sidebar layout via url parameter’ is closed to new replies.