[英]Cannot search products on wp-admin of woocommerce
Scenario: I have my searchbox on my front page of my website. 场景:我的搜索框位于网站首页上。 On that searchbox, I can search the product by SKU and product name. 在该搜索框中,我可以按SKU和产品名称搜索产品。
Problem : I can search a product on client's page/Front-end but not on wp-admin of the website. 问题 :我可以在客户页面/前端上搜索产品,但不能在网站的wp-admin上搜索。
I already tried this : Woocommerce cannot see products in wp-admin , but still no result found. 我已经尝试过: Woocommerce无法在wp-admin中看到产品 ,但仍未找到结果。
Something strange! 奇怪的东西!
Does anybody know? 有人知道吗
For the sake of those developers who may also encounter same problem, that's why I want to put it here for future reference. 为了那些可能也会遇到相同问题的开发人员,这就是为什么我要将其放在此处以供将来参考。
I have been backtracking and searching answers on the internet but I found none. 我一直在互联网上回溯和搜索答案,但没有找到答案。 I tried to review my functions.php inside the theme and found this code below: 我尝试在主题内查看我的functions.php,并在下面找到以下代码:
function __search_by_title_only( $search, &$wp_query ) {
global $wpdb;
$entry = isset($_GET['s']) ? $_GET['s'] : '';
if( $entry ){
$search = "MY SQL QUERY HERE.....";
}
return $search;
}
add_filter( 'posts_search', '__search_by_title_only', 500, 2 );
The above code was inserted inside the functions.php in order to overwrite the query. 上面的代码已插入functions.php内,以覆盖查询。
posts_search
filter, overrrides the product search on my back-end of search though my query was mistaken that's why the problem exists. posts_search
过滤器,虽然我的查询错误,但在我的搜索后端posts_search
了产品搜索,这就是问题存在的原因。
I just removed the code and everything works fine. 我刚刚删除了代码,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.