WordPress.org

Ready to get started?Download WordPress

Forums

Easel
[resolved] How can i enable sidebars ONLY on home page? (5 posts)

  1. GabriDias
    Member
    Posted 1 year ago #

    Hi, i want my sidebars only in my first page, can someone help me? Thanks

  2. Frumph
    Member
    Theme Author

    Posted 1 year ago #

    in the layout-head and layout-foot.php files you can put if statements for if (is_home()) in front of the loading of those sidebars then adjust the CSS for the widths of the narrowcolumn then make another one for body.home .narrowcolumn that has the original width in it

  3. GabriDias
    Member
    Posted 1 year ago #

    I made the first part using if (is_page( array( 35, 12, 52, 'Home' ), but now I have to ajust the body not just in home page, how do i do that? Thank you for the help.

  4. Frumph
    Member
    Theme Author

    Posted 1 year ago #

    This is how you would write that in CSS (dependant on which layout you're using):

    /* this will be full width set as default */
    .narrowcolumn {
         width: 970px;
    }
    
    /* then for each of the other pages that utilize the minor width */
    body.page-id-35 .narrowcolumn,
    body.page-id-12 .narrowcolumn,
    body.page-id-52 .narrowcolumn,
    body.home  .narrowcolumn {
         width: 560px;
    }

    See what I did there? basically setting the default for all pages as the wide width, then each of the ones that I want small width I used CSS (make sure it comes *after* the default in the css) I scrunched the width down.

  5. GabriDias
    Member
    Posted 1 year ago #

    It works! Thank you very much :D

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic