[Support request] Sidebar Filter

Home Forums Support [Support request] Sidebar Filter

Home Forums Support Sidebar Filter

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #602161
    Dan

    Hi
    I am creating a dual language site. English – LTR, Hebrew – RTL.
    In all the Hebrew pages I would like the sidebar to be on the left, except for some pages with no sidebar at all. (Homepage, Contact page)
    So I utlized this filter:

    add_filter( 'generate_sidebar_layout','tu_custom_hebrew_sidebar_layout' );
    function tu_custom_hebrew_sidebar_layout( $layout )
    {
         $currentlang = get_bloginfo('language');
     		
        if ( $currentlang=="he-IL" && !is_front_page()  )
     	 	return 'left-sidebar';
        
     	// Or else, set the regular layout
     	return $layout;
    
     }
    

    The problem is, that it actually overrides the settings of the layout per page (Layout > Sidebars) and adds the sidebar on the left even for pages that I would like to be full-width.
    For the homepage, I solved it with the conditional.
    I would prefer to have an option to override this with the per page setting – is that doable.
    If not, how would I add more pages to omit from having the sidebar on the left?

    Thanks,
    Dan

    #602353
    Tom
    Lead Developer
    Lead Developer

    Hi Dan,

    So if the layout is currently set to full width, you want to keep it full width regardless of the layout?

    add_filter( 'generate_sidebar_layout','tu_custom_hebrew_sidebar_layout' );
    function tu_custom_hebrew_sidebar_layout( $layout ) {
        $currentlang = get_bloginfo('language');
     		
        if ( $currentlang=="he-IL" && 'no-sidebar' !== $layout  )
            return 'left-sidebar';
        }
        
        // Or else, set the regular layout
        return $layout;
     }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.