Full Width Default & Content/Sidebar on Specific Page and Posts - Pro Theme

I have pro theme global content set to full width and would like to keep this for most pages and plugin pages. I was wondering how to make it so a specific page and all posts use the content + sidebar layout and the rest of the site uses full width.

Thanks

Hello There,

Thanks for writing in! Since you want some pages and all posts to use the content + sidebar layout, you must set it globally in X > Launch > Options > Layout and Design > Content Layout. For the other pages that needs to be fullwidth, you will have to edit each of the pages and change the page templates to “Layout - Fullwidth”. To know more about the page templates in X, please check this out:

Hope this helps.

Hey thanks a lot. I tried doing that but there are a lot of plugins like a forum plugin, learning management (Learndash) plugin etc that doesn’t have any way to choose the template and just uses the global default which will show the sidebar instead of being full width. Is there any way to override the global default with plugins maybe using css or some other work around?

Thanks,

Hello There,

Thanks for writing in! Well in that case, you will have to override the layout by using a custom code. Assuming the child theme is set up, please add the following code in your child theme’s functions.php file

// Add sidebars only in single posts
// =============================================================================
function single_post_sidebars($contents) {
  if ( is_single() ) {
    $contents = 'content-sidebar';
  }
  
  return $contents;
}
add_filter('x_option_x_layout_content', 'single_post_sidebars');
// =============================================================================

Now this code will allow sidebar in all your posts. For the specific pages, you will have to edit those pages and make sure of the page templates. If it still displays fullwidth then you will have to include those pages in the code above. The condition of the code will then change to something like this:

if ( is_single() || is_page('123') || is_page('456') ) {

where 123 and 456 is the ID of the page. To know where to get the page id, please check this article:

Hope this helps.

That’s great thanks again I’ll give this a shot.

Hi I tried that code and it worked great to add the side bar to posts while leaving pages full width. The last thing I was trying to solve is that plugins for things like forums and learning management systems content, since these plugins leverage the post.php file they show up with the side bars instead of full width. Is there any way in the theme to override the global content setting so that any plugins and there generated content are set to full width while standard blog type posts have the side bar?

Thanks,

Hello There,

To make sure that only the blog posts will have a sidebar, please change the condition. Please replace is_single() with this:

is_singular('post')

Please let us know how it goes.

Awesome that works, thanks!

Hi I was also wondering how to set the background of the sidebar to be white and a have bit of a drop shadow like the content area?

Thanks,

Also I noticed one more thing is that I set a page to be the blog post index in wodpress settings > Reading > Post Page. Then in the functions I tried targeting it to use the sidebar if ( is_single() || is_page(‘page id here’) but it still has it as full content width. If I remove the page as the post page in the settings it will work to show the sidebar though so the targeting code is working when that setting is off.

Thanks,

Hello Again,

1.) To set the background of the sidebar to be white and a have bit of a drop shadow like the content area, please make use of this code:

.x-sidebar {
    display: block;
    padding: 20px;
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 0.15em 0.35em 0 rgba(0,0,0,0.135);
}

2.) is_page('page id here') will not work when you already assign the page as your blog index. You will have to use this instead:

is_home()

Hope this helps.

That works perfect thank you.

Glad that we could be of a help :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.