Remove Custom Sidebar category

I would like to remove the sidebar from these categories.

here is the css code,
I have excluded but I continue to see a color content:

/*
// Sidebar
*/
.x-main .h-widget, .x-sidebar .h-widget {
background-color: #222222;
border-color: #222222 !important;
}

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

}

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

}

.x-sidebar.right {
background: rgb(248, 248, 248);
padding: 35px;
margin-top: 65px;

}

/sidebar widget title styling/
.x-sidebar h4.h-widget {
color: #ffffff !important;

}

.x-sidebar .widget ul li a, .x-sidebar .widget ol li a {
font-size: 12px;
padding-top: 10px;
padding-bottom: 10px;
color: rgb(68, 68, 68) !important;
font-family: “Helvetica Neue”, Helvetica, sans-serif;
font-weight: 600;
-webkit-font-smoothing: antialiased;
}

.category-bookshop .x-sidebar{
display:none !important;
}

.category-altre-edizioni .x-sidebar.right .x-sidebar{
display:none !important;
}

.category-altre-edizioni .x-main{
width:100% !important;
}

.category-edizioni-labottega .x-sidebar.right .x-sidebar{
display:none !important;
}

.category-edizioni-labottega .x-main{
width:100% !important;
}

Thanks!! :arrossire:

Hello There,

Thanks for writing in! To resolve your issue, please remove this block:

.category-bookshop .x-sidebar{
display:none !important;
}

.category-altre-edizioni .x-sidebar.right .x-sidebar{
display:none !important;
}

.category-altre-edizioni .x-main{
width:100% !important;
}

.category-edizioni-labottega .x-sidebar.right .x-sidebar{
display:none !important;
}

.category-edizioni-labottega .x-main{
width:100% !important;
}

And you should replace it with this code:

.category-bookshop .x-sidebar,
.category-altre-edizioni .x-sidebar,
.category-edizioni-labottega .x-sidebar {
	display:none !important;
}

.category-bookshop .x-main,
.category-altre-edizioni .x-main,
.category-edizioni-labottega .x-main{
	width:100% !important;
}

Please let us know if this works out for you.

There is still. :pensive:

I have this CSS above,
because in other categories I show the custom sidebar:

/*
// Sidebar
*/
.x-main .h-widget, .x-sidebar .h-widget {
background-color: #222222;
border-color: #222222 !important;
}

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

}

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

}

.x-sidebar.right {
background: rgb(248, 248, 248);
padding: 35px;
margin-top: 65px;

}

/sidebar widget title styling/
.x-sidebar h4.h-widget {
color: #ffffff !important;

}

.x-sidebar .widget ul li a, .x-sidebar .widget ol li a {
font-size: 12px;
padding-top: 10px;
padding-bottom: 10px;
color: rgb(68, 68, 68) !important;
font-family: “Helvetica Neue”, Helvetica, sans-serif;
font-weight: 600;
-webkit-font-smoothing: antialiased;
}

Is this what creates problems?
Thanks!

Hi @fra_fantasy,

Please add this CSS, it’s a single page.

    .single-post .x-main {
        width: 100%;
        float: none;
    }
    .single-post .x-sidebar {
     display: none;   
    }

Thanks!

is not there an automatic way for the categories?
so I should add to all the articles

Hi There,

The code provided above by Ruenel should give you what you need.

However, there are 11 errors on your Theme Options > CSS, please check that here, and address that all errors, before you add Ruenel’s code.

Thanks,

I have removed the code. The sidebar errors are just these.
the space of the sidebar remains.

In the php file I have this code for sidebar category “news”:

// Sidebar Categoria //

function assign_custom_sidebar($sidebar){

if (is_singular('post')) {
    $categories = get_the_category(); 
    $mycat = array();
    foreach($categories as $category) {
        $mycat[] =  $category->cat_name;
    }
    if (in_array("CUCINA",$mycat) ){
        return 'ups-sidebar-news';        
    } elseif (in_array("ARTE",$mycat)){
        return 'ups-sidebar-news';        
    } elseif (in_array("LAB",$mycat) ){
        return 'ups-sidebar-news';               
  }
}

return $sidebar;
}

add_filter( ‘ups_sidebar’, ‘assign_custom_sidebar’);

Though I still do not understand. :pensive:

Hello There,

This code will hide the sidebar and make the content area always fullwidth. It only applies to the category pages:

.category-bookshop .x-sidebar,
.category-altre-edizioni .x-sidebar,
.category-edizioni-labottega .x-sidebar {
	display:none !important;
}

.category-bookshop .x-main,
.category-altre-edizioni .x-main,
.category-edizioni-labottega .x-main{
	width:100% !important;
}

The !important can be removed from the code to get rid of the css warnings.

On the other hand, the php code will assign a custom sidebars to each of your blog posts:

// Sidebar Categoria //

function assign_custom_sidebar($sidebar){

if (is_singular('post')) {
    $categories = get_the_category(); 
    $mycat = array();
    foreach($categories as $category) {
        $mycat[] =  $category->cat_name;
    }

    if (in_array("CUCINA",$mycat) ){
        return 'ups-sidebar-news';        
    } elseif (in_array("ARTE",$mycat)){
        return 'ups-sidebar-news';        
    } elseif (in_array("LAB",$mycat) ){
        return 'ups-sidebar-news';               
	}
}
return $sidebar;
}

add_filter( 'ups_sidebar', 'assign_custom_sidebar');

This code will ensure that the News sidebar will always display when the single blog post has a category filed under Arte, Cucina or Lab.

Hope this helps.

Yes, but I would like to remove it in all the individual posts in the specific category.

Hello There,

We are confused. In your original post, you said:

I would like to remove the sidebar from these categories.

And so the custom css given, will get rid of the sidebar and make sure that the content area is fullwidth.

.category-bookshop .x-sidebar,
.category-altre-edizioni .x-sidebar,
.category-edizioni-labottega .x-sidebar {
	display:none !important;
}

.category-bookshop .x-main,
.category-altre-edizioni .x-main,
.category-edizioni-labottega .x-main{
	width:100% !important;
}

Your last reply is:

Yes, but I would like to remove it in all the individual posts in the specific category.

What does this mean? Do you want to remove the sidebar in all posts or only in the post that has the specific category which is Cucina, Arte and Lab?

Regards.

in all post categories “altre-edizioni” and “edizioni-labottega” Sorry :sweat:

At the momento in altre-edizioni I have check fullwidth Post Layout.

Hi,

To achieve that, you can add the code below in your child theme’s functions.php file.

// Remove Sidebar Categoria //

function cat_remove_sidebar($layout){

if (is_singular('post')) {
    $categories = get_the_category(); 
    $mycat = array();
    foreach($categories as $category) {
        $mycat[] =  $category->cat_name;
    }

    if (in_array("Altre Edizioni",$mycat) ){
        $layout = 'full-width';        
    } elseif (in_array("Edizioni Labottega",$mycat)){
        $layout ='full-width';        
    } 
}
return $layout;
}

add_filter( 'x_option_x_layout_content', 'cat_remove_sidebar');

Hope that helps.

Thanks for your precious support!!
:smiley:

You are welcome :slight_smile:

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