[resolved] Search results displayed in different page? (4 posts)

  1. deko
    Posted 6 years ago #

    I'm trying to put a search form on my wp site's front page (not in the sidebar). I'd like it to look almost identical to the search form at the top of this page (this forum's header has a "search wordpress.org" field and a "Go" button).

    Can I use php get_search_form() to do this and display results on a separate page?

    other suggestions?


  2. esmi
    Forum Moderator
    Posted 6 years ago #

    Yes you can. The results will be displayed using the same template file that your theme currently uses to display the results from a search carried out using the form in the sidebar.

  3. deko
    Posted 6 years ago #

    thanks for the tip. I'll dive in and reply back with notes. I've customized my blog so I'm sure some coding will be necessary.



    This tag includes the file searchform.php from your current theme's directory. If that file is not found, it will generate the search form.

  4. deko
    Posted 6 years ago #

    I settled for a basic form/button instead of a stylized one, so it was simply a matter of putting this code in the header:

    <div id="search"><label for="s"><?php _e(''); ?></label><form id="searchform" method="get" action="<?php bloginfo('home'); ?>"><input type="text" name="s" id="s" size="25" />&nbsp;&nbsp;<input type="submit" value="<?php esc_attr_e('Search My Blog'); ?>" /></form></div>

    I used the search.php file from the default theme.

    Too easy.

Topic Closed

This topic has been closed to new replies.

About this Topic