WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Search results displayed in different page?

[Resolved] Search results displayed in different page?

  • 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?

    thx.

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

    @esmi

    Forum Moderator

    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.

    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.


    http://codex.wordpress.org/Include_Tags

    get_search_form

    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.

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Search results displayed in different page?’ is closed to new replies.
Skip to toolbar