Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Hide Search bar from a home page

  • This topic is empty.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #198882
    case1001
    Participant

    Hello,
    I am having a trouble with my search bar. You see i have a home page with a search bar right in the middle of it. I also have a navigation bar on top of the home page with an additional search bar. My question is how do i make it so the additional search bar does NOT appear on the home page but still appears on the other pages. Is there any way to do that?

    #198883
    Senff
    Participant

    Yes, that can be done, most likely. But….we’ll need to see the site so we can tell you what CSS you’ll need to change/add.

    #198885
    case1001
    Participant

    Hello Senff
    this is the website: http://rescore.io

    #198886
    case1001
    Participant

    i am just experimenting at the moment and that is what i have (probably fileld with mistakes)

    <?php if( !is_front_page() ) : ?>
    form action=”/movies/search_by_title”
    input name=”query” type=”text” placeholder=”Search movies” /
    <?php ?>

    #198887
    case1001
    Participant

    basically the initial code is

    li
    form action=”/movies/search_by_title”
    input name=”query” type=”text” placeholder=”Search movies” /

    And what i need to do is say if i am not on the home page execute this bit of code.

    #198893
    Senff
    Participant

    This code…

    <?php if( !is_front_page() ) : ?>
    

    …would indicate you’re working with WordPress, but looking at the site you sent, that’s not a WordPress site?

    If you’re redoing that non-WP site and making it a WP one, then this CSS should just hide the search form from the home page:

    body.home .top-bar form {
        display:none;
    }
    
    #198901
    case1001
    Participant

    And if i just want to leave it non-WP is there anyway to just say if that is the home page don’t show the top right search bar on it ?

    #198902
    Paulie_D
    Member

    Can you give that specific page a class or ID?

    #198903
    case1001
    Participant

    The thing is that i don’t want to do it in WP

    #198904
    Paulie_D
    Member

    Nothing to do with WP….

    I assume you can edit the HTML of the home page, so can you add a class or ID to the body of that page?

    Simple enough question.

    #198905
    case1001
    Participant

    Yes i can do that

    #198907
    Paulie_D
    Member

    Then give the body a class of “home” and follow Senff’s CSS suggestion a few posts up.

    #198909
    case1001
    Participant

    Ok did that and it works. Thanks to both of you :)

Viewing 13 posts - 1 through 13 (of 13 total)
  • The forum ‘CSS’ is closed to new topics and replies.