Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1284510
    Bark201
    Participant

    I want to start re-designing the site for 2017. I would like to add some widgets (banners, images) in the right sidebar of posts, posts only, not pages. I only want banners on the right hand side of posts, not the left. I want the sidebar to show only on PC’s and tablets, not mobile phones.

    Please let me know how can this be achieved and what are the recommended size of the images (in pixels) I can use in the sidebars.

    Also, as I cannot fill the entire sidebar with banners I would like to know if it is possible to make the last image in the sidebar sticky so when the user keeps scrolling down it will stay there.

    #1284565
    Darshana
    Moderator

    Hi there,

    Thanks for writing in! To assist you with this request, 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.

    #1284579
    Bark201
    Participant
    This reply has been marked as private.
    #1284686
    Rupok
    Member

    Hi there,

    Thanks for writing back. It seems you didn’t start yet so not sure where you are facing trouble. You can set the sidebar layout from Customize > Layout and Design. If you need help to hide sidebar for mobile then you can update us after setting the sidebar on your site.

    Hope this makes sense.

    #1285834
    Bark201
    Participant

    I dont have any sidebars because I had no idea how to do it. I created a new sidebar but I dont see an option how I can enable sidebars for posts only and not pages, please help.

    #1285836
    Paul R
    Moderator

    Hi,

    To add sidebar to your posts, you can add this in your child theme’s functions.php

    
    function add_sidebar_posts($contents) {  
      if ( is_singular('post') ) {
        $contents = 'content-sidebar';
      }  
      return $contents;
    }
    
    add_filter('x_option_x_layout_content', 'add_sidebar_posts');
    

    Hope that helps.

    #1285838
    Bark201
    Participant

    I dont want this bounced back and forth. I want to have sidebars in posts only and not pages. If I go to layout I dont have the the option to enable sidebars for posts only. This is the same question I asked yesterday so I dont know why you told me I dont have any sidebars because I asked for your help setting them up.

    #1285844
    Bark201
    Participant

    Thank you for your reply. Please explain to me how to set up the sidebars first because I have no idea. I see the option to create sidebars but I dont see how to enable them for posts only. I would like to resolve it without a code in functions.php. Last time I put a code in there it messed up my site.

    #1285849
    Bark201
    Participant

    I will more clear. I created a new sidebar in manage sidebars and chose a post as a test. The sibebar is not showing. If I allow sidebars through customizer (its on full width now) it will do it on all posts and pages right?

    #1285859
    Bark201
    Participant

    I enabled sidebar on right side from the customizer. What this did is created a sidebar that starts from the top menu all the way down. A sidebar is meant to start from below the top menu and not above it.

    Like I thought, when I enabled it it shows the empty sidebar everywhere. If there is no content it the sidebar it shouldnt show at all but it does.

    All I want is to have a sidebar on the right without having the sidebar starting above the top menu but from the top of the post itself. If there is no content in the sidebar I dont want it to show at all. I am not building a new site so I dont have the time to play around with it, please help.

    #1285930
    Paul R
    Moderator

    Hi,

    Each stack has a unique design and icon stack is designed to have the sidebar start from the top.

    Please check Icon stack demo – http://demo.theme.co/icon-1/

    If the design does not fit for you purpose you can try other stacks.

    You can browse through our demo and select which best suites your purpose – https://theme.co/x/demos/

    With regards to empty sidebars, I will forward your concern to our web development team for review.

    Thanks

    #1286126
    Bark201
    Participant

    thank you for your reply. I do not wish to change the stacks. I personally do not see the logic of having sidebar through the menu but maybe others do. How do I make the sidebars to show only inside the content? In regards to the empty sidebars, yes, I cant customize every sidebar in one day.

    #1286468
    Rad
    Moderator

    Hi there,

    First, you can’t setup specific sidebar without a code. Sidebar is a global feature, having it local to post requires coding.

    Please remove the above code 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_singular('post') ) {
    
    return 'content-sidebar';
    
    }
        return $layout;
    
      }
    
    add_filter( 'ups_sidebar', 'ups_display_post_sidebar' );
    
    function ups_display_post_sidebar ( $sidebar ) {
    
    return is_singular('post') ? 'your-sidebar-id' : $sidebar;
    
    }
    
    

    Then replace your-sidebar-id with your sidebar ID created at Admin > Appearance > Sidebars

    Thanks!

    #1287410
    Bark201
    Participant

    Thank you for the code. I played around with it and I noticed if pages are set to full width it prevent the sidebar from showing, that way it only shows in posts. My question is now that I almost have it as I want, how do I prevent the sidebar showing if its empty, that it has no widgets or content inside it.

    I want to have the sidebar showing for logged out users and not showing for logged in users. I can get it to work using a plugin but the sidebars are still showing empty for logged in users. I hope I am making sense.

    #1287850
    Rad
    Moderator

    Hi there,

    That’s not currently possible since the layout feature is called before the widgets and sidebar filter.

    I guess you could try javascript or CSS to manipulate the layout. Would you mind providing a URL that has no widgets but with sidebar?

    Thanks for understanding.

  • <script> jQuery(function($){ $("#no-reply-1284510 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>