我在我的 Bootstrap 3 站点中添加了一个搜索框,但如果尝试搜索它不会拉出任何结果的内容,它只会刷新您所在的页面:
<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>
我以为是因为我没有 search.php 文件,但是添加后我仍然遇到同样的问题。
搜索.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(); ?>