Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1284882
    yanikphoto
    Participant

    Hello

    My site has content layout default set to “fullwidth” but I want a sidebar just on the main blog page and blog posts. How do I do this? Changing the content layout default set to “content left – sidebar right” isn’t an option as I would have to manually go in and change 100s of pages back to “fullwidth”.

    Thanks!

    #1284965
    Rahul
    Moderator

    Hi There,

    Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.

    Thanks again!

    #1287554
    yanikphoto
    Participant
    #1287692
    Jade
    Moderator

    Hi there,

    Kindly follow the suggestion on this thread.

    Hope this helps.

    #1290369
    yanikphoto
    Participant
    This reply has been marked as private.
    #1290836
    Lely
    Moderator

    Hello Yanik,

    Thank you for the credentials.
    Your settings is correct. Please try to clear cache and then try to check again. We might be seeing cache content.

    #1291328
    yanikphoto
    Participant

    Hello

    I already have the blog index page to not cache but I cleared my cache as well and tried a different browser and the side bar doesn’t show.

    Please help.

    #1291441
    Joao
    Moderator

    Hi There,

    In That case, please go to Appereance > Customizer > Layout and design and choose the general layout with Side Bar.

    On the pages you dont want a sidebar, click Edit Page > On your WordPress classic admin bar > Under the blue update button you can choose the template Blank No Container Header Footer.

    Hope that helps

    Joao

    #1291523
    yanikphoto
    Participant

    Hi

    As I mentioned before, this isn’t an option as I have 100s of pages that I would need to do this on.

    Isn’t there another simple solution?

    #1292208
    Lely
    Moderator

    Hi There,

    Please update the code on your child theme’s functions.php file to this:

    function x_get_content_layout() {
    
        $content_layout = x_get_option( 'x_layout_content', 'content-sidebar' );
    
        if ( $content_layout != 'full-width' ) {
          if ( is_home() ) {
            $opt    = x_get_option( 'x_blog_layout', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( is_singular( 'post' ) ) {
            $layout = 'content-sidebar';
          } 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', 'sidebar' );
              $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
            } else {
              $opt    = x_get_option( 'x_archive_layout', 'sidebar' );
              $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', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( x_is_buddypress() ) {
            $opt    = x_get_option( 'x_buddypress_layout_content', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( is_404() ) {
            $layout = 'full-width';
          } else {
            $layout = $content_layout;
          }
        } else {
    	  if ( is_home() || is_singular( 'post' ) ) {
            $layout = 'content-sidebar';
          else{
    	    $layout = $content_layout;
    	  }
        }
    
        return $layout;
    
      }

    Hope this helps.

    #1292750
    yanikphoto
    Participant

    That code broke my site. My home page was blank.

    #1292866
    Lely
    Moderator

    Hi There,

    We’re sorry for the inconvenience this has caused you. I missed one closing bracket. This updated code should work now:

    
    function x_get_content_layout() {
    
        $content_layout = x_get_option( 'x_layout_content', 'content-sidebar' );
    
        if ( $content_layout != 'full-width' ) {
          if ( is_home() ) {
            $opt    = x_get_option( 'x_blog_layout', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( is_singular( 'post' ) ) {
            $layout = 'content-sidebar';
          } 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', 'sidebar' );
              $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
            } else {
              $opt    = x_get_option( 'x_archive_layout', 'sidebar' );
              $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', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( x_is_buddypress() ) {
            $opt    = x_get_option( 'x_buddypress_layout_content', 'sidebar' );
            $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
          } elseif ( is_404() ) {
            $layout = 'full-width';
          } else {
            $layout = $content_layout;
          }
        } else {
    	  if ( is_home() || is_singular( 'post' ) ) {
                 $layout = 'content-sidebar';
              }else{
    	    $layout = $content_layout;
    	  }
        }
    
        return $layout;
    
      }
    #1292874
    yanikphoto
    Participant

    That didn’t work either. many pages were still blank including the blog page.

    #1293315
    Rad
    Moderator

    Hi there,

    The code is okay, checked it on my installation. Maybe you’re breaking existing code while adding it.

    Please set WP_DEBUG to true under your site’s wp-config.php, and add the code and test it again. Then provide any error you get and make sure you’re appending the code, and no replacing the entire content of functions.php

    And please provide your FTP login credentials as well.

    Thanks!

    #1294197
    yanikphoto
    Participant
    This reply has been marked as private.
  • <script> jQuery(function($){ $("#no-reply-1284882 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>