[Resolved] Sidebar Location

Home Forums Support [Resolved] Sidebar Location

Home Forums Support Sidebar Location

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #608363
    Dan

    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

    GeneratePress 2.1.2
    GP Premium 1.6.2
    #608535
    Tom
    Lead Developer
    Lead Developer

    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;
    }
    #608832
    Dan

    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

    #609145
    Tom
    Lead Developer
    Lead Developer

    There will be an easier way to set layouts under certain conditions ๐Ÿ™‚

    #609149
    Dan

    Great, thanks again.

    Dan

    #609480
    Tom
    Lead Developer
    Lead Developer
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.