【发布时间】:2020-07-21 09:29:35
【问题描述】:
我需要帮助将默认的 Wordpress 搜索替换为 Woocommerce 搜索。
在functions.php中试过这个
add_filter( 'pre_get_posts', 'custom_pre_get_posts' );
function custom_pre_get_posts( $query ) {
if ( is_search() ) {
$query->set('post_type', 'product');
}
return $query;
}
但搜索的输出仍然只是类似帖子的搜索结果列表。我想要与 Woocommerce 搜索输出相同的输出(产品存档)。
这可能吗?
【问题讨论】:
-
您必须在您的主题/子主题中为 search.php 创建一个页面模板。 developer.wordpress.org/themes/template-files-section/…
标签: php wordpress woocommerce