Site logo

Archived topic

Sidebar Filter

1 reply · Started by Dan on June 17, 2018

Viewing posts 1–2 of 2

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

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;
 }
This archived topic is closed to new replies.