WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Searching within the current page or directory instead of entire website (3 posts)

  1. SpyderCanopus
    Member
    Posted 1 year ago #

    When viewing a post or category, instead of searching like this:
    http://www.warriortom.com/?s=elk

    It searches like this:
    http://www.warriortom.com/cumberland-island-turkeys/?s=elk

    Which returns no results most of the time.

    I want the search box to search the whole website every time. :(

  2. SpyderCanopus
    Member
    Posted 1 year ago #

    This is the code for my search box placed in the menu.

    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    <div class="search-form">
    <?php $search_text = "Search WarriorTom.com"; ?>
    <form id="searchform' action="<?php bloginfo('home'); ?>/" method="get">
    <input id="s" onfocus="if (this.value == '<?php echo $search_text; ?>') {this.value = '';}"
    onblur="if (this.value == '') {this.value = '<?php echo $search_text; ?>';}" type="text" name="s" value="<?php echo $search_text; ?>" />
    <input id="searchsubmit" type="hidden" /></form></div>
  3. SpyderCanopus
    Member
    Posted 1 year ago #

    I fixed it! Changed the above code into this and it works now:

    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    <div class="search-form">
    <?php $search_text = "Search WarriorTom.com"; ?>
    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
        <input onfocus="if (this.value == '<?php echo $search_text; ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $search_text; ?>';}" type="text" value="<?php echo $search_text; ?>" name="s" id="s" />
        <input id="searchsubmit" type="hidden" />
    </form></div>

Topic Closed

This topic has been closed to new replies.

About this Topic