• child theme based on GeneratePress 1.2.3
    looked at Exhibit 0.6

    I’m trying to change the width of the left and right sidebars, but not having much success. All the other attributes in this array appear to be are working. Is additional code required to make this work?

    The following is an excerpt from my functions.php

    function set_spacing_defaults()
    {
       $spacing_defaults = array(
      . . .
    			'left_sidebar_width' => '15',
    			'right_sidebar_width' => '15',
      . . .
    
    return $spacing_defaults;			);
    }
    
    function __construct()
    {
    add_filter('generate_spacing_option_defaults', array($this, 'set_spacing_defaults'));
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author Tom

    (@edge22)

    Hi there,

    This should work better:

    add_filter( 'generate_right_sidebar_width', 'generate_custom_right_sidebar_width' );
    function generate_custom_right_sidebar_width()
    {
          return '15';
    }
    
    add_filter( 'generate_left_sidebar_width', 'generate_custom_left_sidebar_width' );
    function generate_custom_left_sidebar_width()
    {
          return '15';
    }

    I should also mention that our Spacing add-on allows you to choose the width super easily through the Customizer.

    Let me know if you have any other questions ??

    Thread Starter Cornelia Villeneuve

    (@codedogs)

    Much better.

    I guess left_sidebar_width and right_sidebar_width assigned in generate_spacing_get_defaults() in spacing.php are obsolete?

    Thank you very much

    Theme Author Tom

    (@edge22)

    Not obsolete, but you have to return the entire list of options if filtering that function, something like this:

    add_filter( 'generate_spacing_option_defaults','generate_new_spacing_get_defaults' );
    function generate_new_spacing_get_defaults()
    {
        $generate_new_spacing_defaults = array(
            'header_top' => '40',
    	'header_right' => '40',
    	'header_bottom' => '40',
    	'header_left' => '40',
    	'menu_item' => '20',
    	'menu_item_height' => '60',
    	'sub_menu_item_height' => '10',
    	'content_top' => '40',
    	'content_right' => '40',
    	'content_bottom' => '40',
    	'content_left' => '40',
    	'separator' => '20',
    	'left_sidebar_width' => '15',
    	'right_sidebar_width' => '15',
    	'widget_top' => '40',
    	'widget_right' => '40',
    	'widget_bottom' => '40',
    	'widget_left' => '40',
    	'footer_widget_container_top' => '40',
    	'footer_widget_container_right' => '0',
    	'footer_widget_container_bottom' => '40',
    	'footer_widget_container_left' => '0',
    	'footer_top' => '20',
    	'footer_right' => '0',
    	'footer_bottom' => '20',
    	'footer_left' => '0',
        );
    
        return $generate_new_spacing_defaults;
    }
    Thread Starter Cornelia Villeneuve

    (@codedogs)

    I had that and yet in did not work.

    I only found references to these 2 filters in extras.php i.e. generate_left_sidebar_classes(), generate_content_classes(), and generate_right_sidebar_classes()

    $right_sidebar_width = apply_filters( 'generate_right_sidebar_width', '25' );
    	$left_sidebar_width = apply_filters( 'generate_left_sidebar_width', '25' );

    There appear to be no references to left_sidebar_width and right_sidebar_width in spacing.php aside from the array declaration. It is likely, this value is not used.

    Theme Author Tom

    (@edge22)

    Interesting – I’ll have to look into that.

    Either way, I’m glad the code from my first post worked ??

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘left/right_sidebar_width not functioning’ is closed to new replies.