- 首页
- PHP
- Wordpress 搜索栏结果是一个空白的白页
Wordpress 搜索栏结果是一个空白的白页
[英] Wordpress Search Bar Result a Blank White Page
本文介绍了Wordpress 搜索栏结果是一个空白的白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的搜索表单
在我的博客侧边栏,它只会搜索博客
.>
这是网站网址:http://dev.wonder.lk/blog/
以下是我应用的搜索类型,
- 博客中可用的值 - 对于某些值,它会给出结果,但有时会显示未找到.Ex : 搜索
hello
(但您可以在存档中看到 Hello World
博客) - 搜索其他
post_type
值 - 结果是一个空白的白页,即使我看不到页眉或页脚.例如:搜索ninja
这是一种产品类型
这些是代码,
search.php
search-post.php
<div class="container blog-wrapper page-container"><div class="row"><div class="col-lg-9 col-md-9 col-sm-12 col-xs-12"><?php if (have_posts()) : while (have_posts()) : the_post();?><?php//包括博客文章列表get_template_part('framework/template-parts/post/blog', 'post-list');?><?php endwhile;?><div class="pagination-wrapper"><?php分页();?>
<?php 其他:?><h3>未找到以下结果:'<?php echo get_search_query();?>'</h3><?php endif;?>
<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12"><?php//包括博客侧边栏get_template_part('framework/template-parts/post/blog', 'sidebar');?>
<?php get_footer();?>
blog-sidebar
和 blog-post-list
是 HTML 结构.
询问我是否需要更多详细信息.
解决方案
更新search.php
后效果很好,
<div class="container blog-wrapper page-container"><div class="row"><div class="col-lg-9 col-md-9 col-sm-12 col-xs-12"><?php if (have_posts()) : while (have_posts()) : the_post();?><?php//包括博客文章列表get_template_part('framework/template-parts/post/blog', 'post-list');?><?php endwhile;?><div class="pagination-wrapper"><?php分页();?>
<?php 其他:?><h3>未找到以下结果:'<?php echo get_search_query();?>'</h3><?php endif;?>
<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12"><?php//包括博客侧边栏get_template_part('framework/template-parts/post/blog', 'sidebar');?>
<?php get_footer();?>
如果我得到一个合理且详细描述的答案,我可以为该答案提供奖励.
I have a simple search form
on my blog sidebar which will search only the blogs
.
<form action="<?php echo get_site_url() ?>" method="GET">
<input type="search" name="s" placeholder="Click to Search" class="fld-search" required/>
<input type="hidden" name="post_type" value="post">
<button class="btn-search"><i class="fa fa-search" aria-hidden="true"></i></button>
</form>
This is the website url : http://dev.wonder.lk/blog/
Following are the search types that I applied,
- Value that available in blog - For some values it gives the result, but sometimes it says not found. Ex : Search
hello
(but you can see the Hello World
blog is there on the archive)
- Search someother
post_type
values - Result is a blank white page, even I can't see the header or footer. Ex : Search ninja
It's a product type
These are the codes,
search.php
<?php
while ( have_posts() ) : the_post();
if(isset($_GET['post_type'])) {
$type = $_GET['post_type'];
if($type == 'product') {
get_template_part( 'woocommerce/archive', 'product' ); //working fine
} else {
get_template_part( 'framework/template-parts/page/search', 'post' );
}
} else {
get_template_part( 'framework/template-parts/page/search', 'post' );
}
endwhile;
?>
search-post.php
<?php
get_header();
//Page Title Bar
$pageTitle = 'Search results for: "'.get_search_query().'"';
echo page_title_bar( $pageTitle, get_template_directory_uri().'/framework/assets/images/pg-title-bar.jpg');
?>
<div class="container blog-wrapper page-container">
<div class="row">
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
// Include Blog Posts List
get_template_part('framework/template-parts/post/blog', 'post-list');
?>
<?php endwhile; ?>
<div class="pagination-wrapper">
<?php pagination(); ?>
</div>
<?php else: ?>
<h3>No results found for: '<?php echo get_search_query(); ?>'</h3>
<?php endif; ?>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
<?php
// Include Blog Sidebar
get_template_part('framework/template-parts/post/blog', 'sidebar');
?>
</div>
</div>
</div>
<?php get_footer(); ?>
blog-sidebar
and blog-post-list
are the HTML structure.
Ask me if you want more details.
解决方案
It worked fine after updating the search.php
as following,
<?php
get_header();
//Page Title Bar
$pageTitle = 'Search results for: "'.get_search_query().'"';
echo page_title_bar( $pageTitle, get_template_directory_uri().'/framework/assets/images/pg-title-bar.jpg');
?>
<div class="container blog-wrapper page-container">
<div class="row">
<div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
// Include Blog Posts List
get_template_part('framework/template-parts/post/blog', 'post-list');
?>
<?php endwhile; ?>
<div class="pagination-wrapper">
<?php pagination(); ?>
</div>
<?php else: ?>
<h3>No results found for: '<?php echo get_search_query(); ?>'</h3>
<?php endif; ?>
</div>
<div class="col-lg-3 col-md-3 col-sm-12 col-xs-12">
<?php
// Include Blog Sidebar
get_template_part('framework/template-parts/post/blog', 'sidebar');
?>
</div>
</div>
</div>
<?php get_footer(); ?>
If I get a reasonable and well described answer I can offer the bounty for that answer.
这篇关于Wordpress 搜索栏结果是一个空白的白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文