How to add a lateral action bar only to the blog posts to the right and align the content to the left?

Hi! This is a post of my blog:

I wonder how to add an action bar to the blog only (not to the rest of the website, only blog posts). I want to align it to the right. The content of the post would be aligned to the left.

In other words: how to add a common sidebar to all the blog posts? How to add the sidebar widgets to all the blog posts only? http://www.edinventa.com/wp-admin/widgets.php

Hi there,

Our theme does not have an option to assign sidebars and widgets to all posts at once. This is a customization request which is outside of our support scope, but we will do our best to show you how to do the customization. Unfortunately, we will not be able to implement the actual customization for you nor maintain the suggested code in the future.

To do so please kindly make sure that you installed a Child Theme to proceed.

  • Go to X > Launch > Options > Layout and Design and make sure you select one of the layouts that have a sidebar:
  • go to X > Launch > Options > Blog and make sure that you select the Use Global Content Layout for all sections there:
  • Go to Appearance > Sidebars and add a sidebar as mentioned in this article.
  • Write down the ID of the sidebar you created for fitire reference:
  • Go to Appearance > Widgets and assign whatever widget you like to the sidebar which you have created in the step above.
  • Find the functions.php file in your child theme and add the PHP code below at the very end of it:
function assign_custom_sidebar($sidebar){
  if ( is_single() ){
    return 'ups-sidebar-blabla';
  }
  return $sidebar;
}
add_filter( 'ups_sidebar', 'assign_custom_sidebar');

You will need to change ups-sidebar-blabla with the sidebar ID which you wrote down in previous steps.

Thank you.

I think it should be some kind of misunderstanding. I’m asking for the most normal thing of WordPress: the blog part.

I have set the CONTENT LAYOUT to Content Left, Sidebar RIght, so the whole website has a sidebar now. Then, it seems I must change all the pages to Layout - Full Width to remove the sidebar from the pages.

However, I have set the Blog part to Mansonry - Full width - Three columns and nothing seems to change. I have read that “This will only affect the posts index page of your blog”, so I have visited edinventa.com/blog. But nothing changed. What does the X > Launch > Options > Blog change?

On the other hand, I don’t know what your proposed child theme would do or what it would change.

Thanks for your patience and help!!

Carlos

Hi there,

The sidebar implementation depends on what theme, and that standard depends on the templates.

Please ignore the above procedures and let’s do it this way.

  1. Go to Appearance > Sidebars and add a sidebar as mentioned in this article.
  2. Write down the ID of the sidebar you created for future reference, example, the ID is in this screenshot
    https://tco-forum-uploads.s3.amazonaws.com/original/3X/2/9/29461e867b9e9e49ff0417f1d8b119bbff7744f7.jpg
  3. Go to Appearance > Widgets and assign whatever widget you like to the sidebar which you have created in the first step.

The above 3 steps are optional so further procedures may vary, let’s continue

  1. If you don’t have any child theme yet, then please install one and activate it (you may find more information here https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57 )
  2. 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_home() ||  is_singular( 'post' ) ) {
$layout = 'content-sidebar';
}
    return $layout;

  }

Note: Append it to the child theme’s functions.php and don’t overwrites what’s in there. And you will have to use FTP or your hosting’s file manager to edit the child theme’s functions.php

This code bypass the settings you have in X > Launch > Options > Blog and X > Launch > Options > Layout and Design. And because blog layout usually inherits the layout from Layout and Design, you wouldn’t see any difference if the global layout is set to full-width (no sidebar). The workaround is that code :slight_smile:

  1. Remember the first 3 procedures above?

-------- If you choose to follow those 3 procedures, then add this code to your child theme’s functions.php too

function assign_custom_sidebar($sidebar){
  if ( is_single() ){
    return 'ups-sidebar-blabla';
  }
  return $sidebar;
}
add_filter( 'ups_sidebar', 'assign_custom_sidebar');

You must also change the ups-sidebar-blabla with the ID of the sidebar you created. Like from here

-------- If you choose to ignore those 3 procedures, then no need for additional codes. What you need to do is add your widgets to your MAIN SIDEBAR in Admin > Appearance > Widgets. If you don’t define custom sidebar and ID then it will use the main sidebar automatically .

Hope these helps :slight_smile:

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