Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hiding header search box other than specific page


  • mairaj
    Participant

    @mairaj

    Hello,

    I wonder if it is possible to remove the header search box from bp-default theme but keep it in a one specific page which is password protected or private.

    Or if not the above is there a short-code available which can be inserted in a page body / content area to produce the search box?

    I basically want to restrict the member search by their user name or real name but wish to keep this for admin use.

    Thank you for the help.

Viewing 3 replies - 1 through 3 (of 3 total)

  • @mercime
    Participant

    @mercime

    @mairaj

    – Create a bp-default child theme -> https://codex.buddypress.org/theme-development/building-a-buddypress-child-theme/
    – Copy header.php from bp-default theme to your child theme folder then remove the search div from the header.php in you child theme folder
    – Create a Page Template -> https://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates and add the code your deleted from header.php replacing the_content tag and upload to your child theme folder in server
    – Pages > Add New and title it whatever you want then choose the template in sidebar then make it private, Admin can access that page anytime.


    mairaj
    Participant

    @mairaj

    Thank you very much for your reply. This seems to be simpler and I will try this.

    However, while searching for a solution for this problem, I found a css code to try removing search box. The code is as follows
    `.registration #search-form, .activation #search-form { display: none; }`
    Then, I used
    `.page-id 20 #seach-form { display: none; }`
    Removed it from all the pages, except the one I wanted to keep it on.
    I figured out using ‘page’ (.page #search-form { display: none; }) removes the box from every page but not blog posts and bp pages (like profile, activity etc.)

    Can you help me know how to define ‘blog posts’ and ‘buddypress pages’ to remove the search box from those pages too. I want to say something like following:

    `.post #seach-form { display: none; }`
    and
    `.bp-page #seach-form { display: none; }`

    I have tried ‘post’, ‘posts’, ‘post-page’, ‘blog’, ‘blog-page’ etc. and many values for buddypress pages as well but nothing works out.

    Please help me figure out the value to put to define the page types.

    Thank you very much again :)


    @mercime
    Participant

    @mercime

    @mairaj know that if user disables styles in browser, they will see the search form. But should you still want to proceed with your method, these two lines should do it via CSS

    `/* Hide search form in ALL pages */
    #search-form { display: none; }

    /* Then show search form on this page only (change page ID to your installation’s page ID) */
    body.page-id-25 #search-form { display: block; }`
    You might have to add some width or float after display block depending on how you’ve styled the child theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hiding header search box other than specific page’ is closed to new replies.
Skip to toolbar