【发布时间】:2019-03-11 05:41:17
【问题描述】:
我的 WordPress 主题(“悉尼”)显示搜索结果有误。我只想显示 WooCommerce 产品,而不仅仅是列出帖子。
这些应该排列在一个漂亮的网格中,如下图所示:
。
目前结果是这样列出的
.
如何更改搜索结果的显示方式?
目前我的search.php 是这样的:
<?php get_header(); ?>
<div id="primary" class="content-area col-md-9">
<main id="main" class="post-wrap" role="main">
<?php if ( have_posts() ) : ?>
<header class="page-header">
<h3><?php printf( __( 'Search Results for: %s', 'sydney' ), '<span>' . get_search_query() . '</span>' ); ?></h31>
</h3>
</header><!-- .page-header -->
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/**
* Run the loop for the search to output the results.
* If you want to overload this in a child theme then include a file
* called content-search.php and that will be used instead.
*/
get_template_part( 'content', 'search' );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
非常感谢你们!
** 更新 kashalo 提供的解决方案部分有效,但搜索结果与产品页面看起来仍然略有不同,并且仅列在一列而不是网格中。
** 更新
Alexander Wigmore 建议的解决方案看起来几乎是我想要的样子。将page.php 复制到search.php 中的唯一问题是,产品仍会显示为wheird,但不是在它们显示在它们适合的类别中时。例如:当搜索saat 结果最初仅以文本显示产品,但通常在 Saatgut 类别下。
【问题讨论】:
-
您需要更改
content-search.php而不是您在上面发布的这个文件 -
问题是我没有完整的数据库访问权限,并且 content-search.php 没有显示在 WordPress 编辑器中。
-
这个文件不在你的主题导演的数据库中
-
你的店铺页面的样式和上图一样吗?
-
是的,这些截图是我店的原始截图。
标签: php wordpress search woocommerce