Change blog layout

Hi,

I am hoping you can help me in regards to my blog page. My global layout is set as fullwidth, which I am wanting to leave as this, however, I’m not sure how I now go about displaying a custom sidebar on my blog page. I am only wanting the sidebar to be shown on this page. If I either select global layout or fullwidth it restricts displaying sidebar. Could you please let me know what I can do to make this change.

http://bbclub.com.au/recipes/

Many thanks!
Naomi

Hi There,

Please add the following code under functions.php file locates in your child theme:

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 = 'content-sidebar';
      } 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_home() ) {
    	$layout = 'content-sidebar';
    }

    return $layout;

}

Thanks so much!

This worked great, however, I have now lost my top margin which I need so that it is not behind the header. I have the following css set as global:

.x-main.full {
margin-top: 100px;
}

Could you now please let me know how I can add this top margin back to this page.
Many thanks,
Naomi

Hello there,

To rectify this error, may you apply the following custom CSS in Customize --> Custom --> CSS please:

.x-main{
margin-top: 100px;
}

.x-sidebar{
  margin-top: 100px;
}

I hope this helps :slight_smile:

Awesome! Thank you! This worked perfectly! :slight_smile:

You’re welcome! :slight_smile:

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