dongyumiao5210 2014-01-02 08:59
浏览 91

Bootstrap 3搜索框没有显示任何结果

I added a search box to my Bootstrap 3 site but if try searching for something it doesn't pull up any results, it just refreshes the page you are on:

see this

<form class="navbar-form" role="search">
  <div class="form-group">
    <input type="text" class="form-control" placeholder="Search">
  </div>
  <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
</form>

I thought it was because I didn't have a search.php file but I am still experiencing the same problem once I added it.

search.php

<?php
/**
 * The template for displaying Search Results pages
 *
 * @package WordPress
 * @subpackage Wp_Bootstrap
 * @since Wp Bootstrap 1.0
 */

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

        <?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'wpbootstrap' ), get_search_query() ); ?></h1>
            </header>

            <?php /* The loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'content', get_post_format() ); ?>
            <?php endwhile; ?>

            <?php wpbootstrap_paging_nav(); ?>

        <?php else : ?>
            <?php get_template_part( 'content', 'none' ); ?>
        <?php endif; ?>

        </div><!-- #content -->
    </div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
  • 写回答

3条回答 默认 最新

  • doufu1950 2014-01-02 09:05
    关注

    your form <form class="navbar-form" role="search"> tag didn't contain an action and you need to give the input text a name

    <form class="navbar-form" role="search" action="<?php esc_url( site_url() ) ?>" method="get">
        <div class="form-group">
           <input name="s" type="text" class="form-control" placeholder="Search">
        </div>
           <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
    </form>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试