简体   繁体   English

我的搜索表单正在重定向到主页。 怎么解决?

[英]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 这是网站: http : //plugr.nl

Addition: The HTML 加法: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 /-->

Looks like this search URL is what your template is expecting: http://plugr.nl/?s=waar 看起来此搜索URL就是您的模板所期望的: 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. 将输入名称更改为“ s”,然后查看对您有用。

You might need to grep through the files in your template to find where this form is actually generated. 您可能需要grep浏览模板中的文件,以查找实际生成此表单的位置。 Nested template files will not show up in the wordpress GUI editor. 嵌套的模板文件将不会显示在wordpress GUI编辑器中。 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. 您的搜索表单也可能是通过模板所依赖的小部件提供的,因此您可能需要进一步挖掘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM