WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. deko
    Member
    Posted 4 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?

    thx.

  2. esmi
    Forum Moderator
    Posted 4 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
    Member
    Posted 4 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.


    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.

  4. deko
    Member
    Posted 4 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