Remove sidebar and format page on dynamically created register and thank you pages

Hi,

If you look here:

https://followtheboat.com/register/bosun/

The page layout is exactly what I’m after except I’d like to remove the sidebar.

This is the same for what I think is a dynamically-created page here:

https://followtheboat.com/register/bosun/?action=checkout&txn=14#mepr_jump

And then once subscribed the user is sent to a thank you page

https://followtheboat.com/thank-you-2/?membership=bosun&trans_num=cus_FyaqS7HQgSlviq&membership_id=40292&subscr_id=cus_FyaqS7HQgSlviq#mepr_jump

The thank you page I can choose the layout but I need to replicate the grey box that appeared on the first page, and, if possible, include my bbpress sidebar that’s been configured in widgets.

In fact, thinking about it, all my pages, when they are ‘default layout’ appear to include the sidebar. Often I don’t need this so maybe I need to make a blanket ‘remove sidebar’ from pages?

Thanks

Hi @demonboy,

Thank you for writing in, please navigate to Theme Options > Layout and Design, and set the Content Layout to Fullwidth


To add a grey background to your thank you page, please add this to the Page > CSS area.

.x-container.max.width.offset {
	background-color: #f8f8f8;
}

For the “thank you” page redirection, please read the following article.

Cheers!

Hi friech,

Of course, it’s that option! However, if I set my layout to full width then I lose all the pages that require a side-bar, so I guess I am stuck with either adding it when I need it in full width, or removing it when I don’t need it. Does this option affect posts as well as pages? All my posts have sidebars.

Also, I checked my thank you page and it already has the grey background, it’s just the padding that needs changing. The code you supplied seems to be a blanket css for all pages, not just the thank you page.

So, back to those dynamically created Register pages - how to remove the sidebar? The ‘register’ page itself is set to full width. When you view just the register page, it shows the WP registration form but no grey background. This is fine as I’ll do a redirect to the memberpress register page instead. However the register/bosun page (and all other register/memberpress member levels) shows the correct grey background but with the sidebar. How to remove it?

Hi @demonboy,

Yes, it does apply to posts and pages since the layout is global.

If you’re referring to the gap in between then it is a space and not an actual element or structure then it’s colorless an can’t be changed. The padding always takes the color of the container’s background.

And you can change that CSS to target the thank-you page

.page-id-40286 .x-container.max.width.offset {
	background-color: #f8f8f8;
}

As for removing sidebar, perhaps we can go with template code and to override the layout settings too. For that, please add this code to your child theme’s functions.php

  function x_get_content_layout() {

    $content_layout = x_get_option( 'x_layout_content' );

    if ( $content_layout != 'full-width' ) {
      if ( is_home() ) {
        $opt    = x_get_option( 'x_blog_layout' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
      } elseif ( x_is_portfolio_item() ) {
        $layout = 'full-width';
      } elseif ( x_is_portfolio() ) {
        $meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
        $layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
      } elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
        $layout = 'content-sidebar';
      } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
        $layout = 'sidebar-content';
      } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
        $layout = 'full-width';
      } elseif ( is_archive() ) {
        if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
          $opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        } else {
          $opt    = x_get_option( 'x_archive_layout' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        }
      } elseif ( x_is_product() ) {
        $layout = 'full-width';
      } elseif ( x_is_bbpress() ) {
        $opt    = x_get_option( 'x_bbpress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( x_is_buddypress() ) {
        $opt    = x_get_option( 'x_buddypress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_404() ) {
        $layout = 'full-width';
      } else {
        $layout = $content_layout;
      }
    } else {
      $layout = $content_layout;
    }


if ( is_bbpress() ) {
 $layout = 'full-width';
}

    return $layout;

  }

It’s the theme’s layout original code, and I only added this code to the above one

if ( is_bbpress() ) {
 $layout = 'full-width';
}

To make sure all bbpress pages will have no sidebar.

Hope this helps.

I assume I have to then set the layout to Full Width in X’s options? This has corrected the sidebar appearing in the pages but it has still made my blog posts full-width (i.e. I’ve lost the sidebar). I’m assuming that’s because of this line:

 } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;

How do I ensure the blog posts have the sidebar?

BTW, I removed the bbpress full-width part as the bbpress section should have the sidebar.

Hello @demonboy,

To make sure that the single blog posts have a sidebar, please go to X/Pro > Theme Options > Layout and Design > Content Layout and make sure that you have set it to “Content Left, Sidebar Right” or “Sidebar Left, Content Right”. This is the global setting that the single blog posts used.

And if that settings still does not have any effect, then you might need this custom override function in your child theme’s functions.php file:

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

Take note of the content-sidebar as you can use sidebar-content as well.

Hope this helps.

To make sure that the single blog posts have a sidebar, please go to X/Pro > Theme Options > Layout and Design > Content Layout and make sure that you have set it to “Content Left, Sidebar Right” or “Sidebar Left, Content Right”. This is the global setting that the single blog posts used.

That’s what I had it set to originally. I’ve changed it to full-width in order to remove the sidebar from all the other pages.

If I insert this into my functions.php

function add_sidebars_singleposts($contents) {
  if ( is_single() ) {
    $contents = 'content-sidebar';
  }
  
  return $contents;
}

It doesn’t do anything (I’ve left ‘full-width’ ON). I thought it might be because of this:

 } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;

…which I tried removing, but this had no effect either. The blog posts are still displaying full-width. I thought that irrespective of whether the global layout is set to full-width, the functions.php should over-ride this, no?

Sorry, scrap that. I’m getting ‘site’ layout and ‘content’ layout confused, my apologies. I think I have this sorted now, thanks.

aaaaand no I haven’t. The registration page is STILL showing the sidebar, despite the ‘register’ page being set to full-width. See here:

https://followtheboat.com/register/bosun/

So despite adding all this extra code into functions.php we are back where we started.

Please advise…

Hello @demonboy,

Do you really to have a fullwidth pages sitewide? If that is the case, do the following:

  • Remove any code that is related to the layout
  • Set the X/Pro > Theme Options > Layout and Design > Content Layout opn to fullwidth and let the Theme Option global layout setting be applied to the rest of the pages.

Hope this helps.

I have site layout set to ‘full width’, and content layout set to ‘content left, sidebar right’. When set like this and with the code you supplied above placed into function.php, my blog posts have the sidebar, as required, but so do my pages, and the pages are placing the sidebar UNDERNEATH the content. See this page and scroll down:

https://followtheboat.com/register/bosun/

I don’t want the sidebar to appear on pages.

Hey @demonboy,

Before leading you to the right direction regarding your sidebar problem, I’d like us to forget about these 2 things first:

  1. The Site Layout option is not related to the Sidebar. It’s the Content Layout that is being used by posts, default page template and the single template of custom post types.

  2. This code provided previously is not related to layout. You can remove or comment it out.

I’d also like to clarify that your registration page is a MemberPress page and not a default WordPress page post type. It is important to identify what the page type so you can use it in when overriding the x_get_content_layout.

If you look at the x_get_content_layout, you’ll see conditions and the 3 Content Layout values and where they get the values.

Knowing that, you’ll be able to override the layout for any page type. You can either add a new endif block or find a full-width layout block and add a WordPress, theme or plugin’s conditional to the endif line like in the screenshot below.

Now the sidebar is gone in your registration page.

Hope that helps.

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