Site logo

Archived topic

Sidebar Location

5 replies · Started by Dan on June 25, 2018

Viewing posts 1–6 of 6

Hi
I have a multilingual site (English, Hebrew)
The hebrew site is RTL so, I wanted the sidebar to be on the left side of the page.
I used this function:


//Sidebar hebrew location
add_filter( 'generate_sidebar_layout','tu_custom_hebrew_sidebar_layout' );
function tu_custom_hebrew_sidebar_layout( $layout )
{
     $currentlang = get_bloginfo('language');
 	
 	
    if ( is_page( array( '320','237') )|| is_category() ) {
    return false;
}
    
    
    if ( $currentlang=="he-IL" && !is_front_page()  )
 	 	return 'left-sidebar';
    

 	// Or else, set the regular layout
 	return $layout;

 }

The problem is that this function over-rides the settings on a per-page basis, which means I cannot remove the sidebar with the GP UI, only if I remove it via the function.
Question is:
1. Am I using this function correctly?
2. Is there a better way to move the sidebar to the left on RTL pages and still have the GP over-ride functionality.

Thanks in advance,
Dan

Hi there,

GPP 1.7 (currently in private alpha) will have an easy solution for this.

For now, try adding this at the top of your function (before any other conditions):

$meta = get_post_meta( get_the_ID(), '_generate-sidebar-layout-meta', true );
if ( $meta ) {
    return $meta;
}

Hi Tom, thanks.
That did it.
So this will be the built-in default behaviour for 1.7?

Sounds great, thanks again for your support!

Dan

There will be an easier way to set layouts under certain conditions :)

Great, thanks again.

Dan

You're welcome :)

This archived topic is closed to new replies.