WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Trying to hide header on certain pages (3 posts)

  1. ianbee
    Member
    Posted 1 year ago #

    I'm trying to hide my header div on certain pages. Right now the div I'm trying to hide on certain pages is called "slideshow"... here's the coding I'm using.

    .home #slideshow {
    display: none;
    }

    ".home" sucesfully hides the header ( the slideshow div) from the home page. But when I try to hide pages titled "bio" or "events" it doesn't work (I tried replacing .home with .bio to hide the bio page and even tried the id for that page, still doesn't work).

    Does anyone know what I'm doing wrong or how to hide specific div's / the header on certain pages?

  2. ianbee
    Member
    Posted 1 year ago #

    Ok i figured out how to fix it, kinda. Here's the coding I used to only show the header on the home page:

    <?php if( is_home() ) { ?>
    <div id="slideshow">content</div>
     <?php } ?>

    Here's the thing. My home page is a static page. And my blog posts are set to display on my "news" page. So instead of only showing the header on my real home page, it only shows the header on the blog posts page (news).

    How would I set it up so the header is only showing on my home page (which is a static page), and not the posts page?

  3. ianbee
    Member
    Posted 1 year ago #

    Found it out myself, since my homepage is a static page, the "is_home" code is directing itself to what it thinks is my homepage, a.k.a my blog posts page.

    So instead of this code:

    <?php if( is_home() ) { ?>
    <div id="slideshow">content</div>
     <?php } ?>

    I used:

    <?php if( is_page( 'home' ) ) { ?>
    <div id="slideshow">content</div>
     <?php } ?>

    Now, the code is telling to only show the header in the page "home", not what it thinks is the home page.

    You can replace home with any page title you have and it should work

    Thanks for nothing guys,
    just kidding! :)

Topic Closed

This topic has been closed to new replies.

About this Topic