Bart D.
Bart D.

Reputation: 13

My search form is redirecting to the homepage. How to solve?

Everytime when I try to search on my website, it keeps returning to the homepage. I have a search form though, built-in with my theme. Can't find the problem. Can you help me?

<?php get_header(); ?>
<div class="content">
    <?php tie_breadcrumbs(); ?>

    <div class="page-head">
        <h2 class="page-title">
            <?php if ( have_posts() ) : ?>
            <?php printf( __( 'Search Results for: %s', 'tie' ), '<span>' . get_search_query() . '</span>' ); ?>
            <?php else : ?>
            <?php _e( 'Nothing Found', 'tie' ); ?>
            <?php endif; ?>
        </h2>
        <div class="stripe-line"></div>
    </div>

    <?php if ( have_posts() ) : ?>
        <?php get_template_part( 'loop', 'search' );    ?>
        <?php if ($wp_query->max_num_pages > 1) tie_pagenavi(); ?>
    <?php else : ?>
        <div id="post-0" class="post not-found post-listing">
            <div class="entry">
                <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'tie' ); ?></p>
            </div>
        </div>
    <?php endif; ?>
</div>
<?php get_sidebar(); ?>

This is the website: http://plugr.nl

Addition: The HTML

    <?php if(tie_get_option( 'top_right' ) == 'search'): ?>
                <div class="search-block">
                    <form method="get" id="searchform" action="<?php echo home_url(); ?>/">
                        <button class="search-button" type="submit" value="<?php if( !$is_IE ) _e( 'Search' , 'tie' ) ?>"></button> 
                        <input type="text" id="s" name="s" value="<?php _e( 'Search...' , 'tie' ) ?>" onfocus="if (this.value == '<?php _e( 'Search...' , 'tie' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Search...' , 'tie' ) ?>';}"  />
                    </form>
                </div><!-- .search-block /-->

Upvotes: 1

Views: 4584

Answers (2)

Gillmour Tunhira
Gillmour Tunhira

Reputation: 1

You need to place "s" for the name value...name="s". Its a default setting for wordpress which will detect this variable for what kind of search you did.. /?s="whatever you searched for"

Upvotes: 0

Gopherkhan
Gopherkhan

Reputation: 4342

Looks like this search URL is what your template is expecting: http://plugr.nl/?s=waar

Your form has code like:

<form method="get" id="searchform" action="http://plugr.nl/">
    <input type="text" name="inputBox" placeholder="Typ wat je zoekt en druk op enter">
</form>

Change the input name to "s" and see what that does for you.

You might need to grep through the files in your template to find where this form is actually generated. Nested template files will not show up in the wordpress GUI editor. It's also possible your search form is provided through a widget which the template depends on, so you might need to dig a little further.

Upvotes: 1

Related Questions