• Resolved pikatxu77

    (@pikatxu77)


    Hi everyone,

    I’m not a programmer, I take hours searching for the net solution to this and I have not managed to find it ?? Hopefully someone knows the solution.

    I would like to remove the sidebar that appear in the categories pages.
    A code could be put in the functions.php would be great, also by eliminating the sidebar content suits fill that space (fullwidth).

    Thanks if anyone can help

    (sorry for my english, is not very good)

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter pikatxu77

    (@pikatxu77)

    Thanks Menaka for your support!

    Unfortunately I do not understand which code I have to put to delete the sidebar from categories.

    But it’s my fault not understand programming ??

    Thank you!

    Hi,
    Add this to you child theme’s functions.php and modify to suit your needs.

    add_filter('tc_global_layout', 'my_custom_layout' );
    
    function my_custom_layout( $layout ) {
    
        $my_layout_for_categories      = array(
            'r' => array ('content' => 'span12' , 'sidebar' => false),
            'l' => array ('content' => 'span12' , 'sidebar' => false),
            'b' => array ('content' => 'span12' , 'sidebar' => false),
            'f' => array ('content' => 'span12' , 'sidebar' => false),
        );
    
        if ( is_category() ) {
            $my_layout = $my_layout_for_categories;
        } 
    
        //sets new values for content and sidebar (checks if there are new values to set first)
        foreach ($layout as $key => $value) {
            $layout[$key]['content']   = isset( $my_layout[$key]['content']) ? $my_layout[$key]['content'] : $layout[$key]['content'];
            $layout[$key]['sidebar']   = isset( $my_layout[$key]['sidebar']) ? $my_layout[$key]['sidebar'] : $layout[$key]['sidebar'];
        }
    
        return $layout;
    }

    Thread Starter pikatxu77

    (@pikatxu77)

    Hi Menaka, thanks for you support.

    I put the code works almost well, the sidebar is gone ?? but I get two problems:
    1. A strip shown in media hides the contents:
    https://prnt.sc/c9fajs

    2. The content previously appeared in the sidebar is now displayed at the end of the page’s content ?? I do not want to appear:
    https://prnt.sc/c9faue

    Eliminating the line:
    $layout[$key]['sidebar'] = isset( $my_layout[$key]['sidebar']) ? $my_layout[$key]['sidebar'] : $layout[$key]['sidebar'];

    Fixed so the range shown in the middle (1) ??

    Would fail to fix the point 2 and then it works perfectly

    Hi,
    So, have your solved the issue? Or is there any issue still?

    Thread Starter pikatxu77

    (@pikatxu77)

    Hi, there is an issue to solved.
    The content displayed on the sidebar now appears at the end of the category page:
    https://prnt.sc/c9faue

    Hi,
    I do not see this behaviour in my local environment.
    Can you show what your settings for layout are (in the customiser panel)?

    Thread Starter pikatxu77

    (@pikatxu77)

    Hi Menaka,

    Thanks for the support and apologies for the delay in responding, I spent a few days away and I had not internet access.

    With the code:

    add_filter('tc_global_layout', 'my_custom_layout' );
    function my_custom_layout( $layout ) {
    
        $my_layout_for_categories      = array(
            'r' => array ('content' => 'span12' , 'sidebar' => false),
            'l' => array ('content' => 'span12' , 'sidebar' => false),
            'b' => array ('content' => 'span12' , 'sidebar' => false),
            'f' => array ('content' => 'span12' , 'sidebar' => false),
        );
    
        if ( is_category() ) {
            $my_layout = $my_layout_for_categories;
        } 
    
        //sets new values for content and sidebar (checks if there are new values to set first)
        foreach ($layout as $key => $value) {
            $layout[$key]['content']   = isset( $my_layout[$key]['content']) ? $my_layout[$key]['content'] : $layout[$key]['content'];
        }
    
        return $layout;
    }

    The sidebar disappears but its content is now displayed at the bottom of the page. Quoting an image where you can see an example and know a url where this happens:

    https://prnt.sc/cd3mt7

    Thread Starter pikatxu77

    (@pikatxu77)

    Hi,
    Anything about it know?
    Can you solve?

    Thanks

    Hi,
    Please post your site url. It might be a case of an unclosed html div. To check what went wrong, I need the url.

    Thread Starter pikatxu77

    (@pikatxu77)

    Hi Menaka, thanks for the support.

    Here a page where this happens:
    https://mundoasistencial.com/enfermedades/

    Thanks

    Thread Starter pikatxu77

    (@pikatxu77)

    Anything known? It can be fixed?

    Thanks

    Hi,
    Add this as well to your child theme’s functions.php

    add_filter('tc_sidebar_display','my_sidebar_display');
    function my_sidebar_display($content) {
      if(is_category()){
    	return null;
      }
      return $content;
    }
    Thread Starter pikatxu77

    (@pikatxu77)

    It works! You’re a genius, many thank you very much!

    Glad ??
    Can you mark this post as resolved?

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘remove sidebar in category pages’ is closed to new replies.