Hide sidebars from Category pages

Community Forums Forums Design Tips and Tricks Hide sidebars from Category pages

This topic is: resolved

This topic contains 7 replies, has 3 voices, and was last updated by  michiganseo 1 year, 4 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #46929

    wyattwerner
    Participant
    Post count: 16

    I’m using the Education theme, and have it set up to have two sidebars as its default layout. I have a few items in the navigation that lead to category pages, but I don’t want those pages to have sidebars.

    How can I hide the sidebar areas on a category page?

    Thanks in adavance!

    http://www.idahodairymens.org/category/letters-opinions/
    #46933

    braddalton
    Participant
    Post count: 10565

    You can use CSS or PHP code.

    CSS: Use the class for sidebars and the body class for category pages with display: none as the declaration.

    PHP: Would need to write a custom function.


    #46937

    wyattwerner
    Participant
    Post count: 16

    I was hung up on the idea that I didn’t have a page ID, but I can just use the category id. Bleh! Thanks!

    I did this:

    .category-11 .sidebar {
    display:none;
    }

    I also made the content area wider to fill in the space left by the hidden sidebar:

    .category-11 #content {
    width: 875px;
    }
    #48024

    michiganseo
    Participant
    Post count: 6

    wyattwerner,

    On your home page, I noticed that both the blog posts are removed AND the PRIMARY SIDEBAR. How did you remove both of these from the homepage. I would like to do something similar.

    Thanks!

    #48032

    wyattwerner
    Participant
    Post count: 16

    @michiganseo:

    I added two lines of code to the bottom of functions.php (not my magic; I found it somewhere in the forum):

    remove_action( 'genesis_loop', 'genesis_do_loop' );
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    
    genesis();

    Leave out the final “genesis” line; that’s just to show where I put it in the file.

    #48065

    michiganseo
    Participant
    Post count: 6

    @wyattwerner:

    Thank you so much for your response. That code removed the primary sidebar from all pages. I’m just looking to remove the primary sidebar from the home page — similar to what you seem to do here: http://www.idahodairymens.org. Please let me know if you have a thought on that… Thanks again so much for your help!

    #48088

    wyattwerner
    Participant
    Post count: 16

    Aha! Sorry.

    Don’t do this in functions.php, but rather in home.php. That’ll affect only the home page.

    #48093

    michiganseo
    Participant
    Post count: 6

    That makes sense… Adding those 2 lines of code to home.php eliminated the posts from displaying; however, the primary sidebar is still visible… strange… thanks for your efforts!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.