Site logo

Archived topic

Changing layout sidebars with a hook

6 replies · Started by Alberto on March 19, 2018

Viewing posts 1–7 of 7

Hello.
I'm trying to change the layout in a particular page using this code in functions.php

function dom_barra_en_especialidades( $layout ){
    if ( is_page('the-slug') ){
        return 'left-sidebar';
    } else {
        return $layout;
    }
}
add_filter( 'generate_sidebar_layout','dom_barra_en_especialidades' );

The default setting is to Content with no sidebars, but I want the left sidebar in that page. I'm still getting the default layout.
Where I'm getting wrong?

Thanks in advance.

Hi Leo.
Yes, is a static page, and Yes, I've just tried the sidebar metabox but I can't see the left sidebar in the page layout.

Regards

It would be the Sidebar/Content option.

Hello
Ok, It seems there's an issue using Sections with this.
If I set Sidebar/Content in the metabox in the page and I don't use Sections, it actually shows the left sidebar. But if I use Sections, the sidebar is not displayed.
Is there a way to solve this?

Regards.

Glad you figured out!

This archived topic is closed to new replies.