wordpress - Wordpress 搜索代码在本地主机上工作,但不在实时环境中
问题描述
我是一名业余的自学成才的 wordpress 开发人员。我实际上正在研究我的第二个自定义主题。
在这个特定的主题中,我有一个搜索表单,可以使用多个自定义字段从自定义帖子类型“个人资料”中进行搜索。
我在 WordPress 搜索页面上有这段代码。
$search = $_GET['s'];
$pre_meta_query = array(
'relation' => 'OR',
array(
'key' => 'profileName',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'profileServices',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'profileBio',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'profileLocation',
'value' => $search,
'compare' => 'LIKE'
),
array(
'key' => 'profileBusinessTel',
'value' => $search,
'compare' => 'LIKE'
),
);
//A Basic
$args = array(
'posts_per_page' => - 1,
'orderby' => 'rand',
'order' => 'ASC',
'post_type' => 'profile',
'post_status' => 'publish',
/*'exact' => false,
's' => $search,
'sentence' => true,*/
'meta_query' => $pre_meta_query
);
$query = new WP_Query( $args );
$profiles = $query->posts;
它适用于我的 xampp 安装而不是实时安装环境。当我检查错误日志时,我收到以下错误:
'ads_postmeta' for query SELECT ads_posts.*
FROM ads_posts
INNER JOIN ads_postmeta ON ( ads_posts.ID = ads_postmeta.post_id )
INNER JOIN ads_postmeta ON (ads_posts.ID = ads_postmeta.post_id)
WHERE 1=1
AND (
( ads_postmeta.meta_key = 'profileName' AND ads_postmeta.meta_value LIKE '%umo%' )
OR
( ads_postmeta.meta_key = 'profileServices' AND ads_postmeta.meta_value LIKE '%umo%' )
OR
( ads_postmeta.meta_key = 'profileBio' AND ads_postmeta.meta_value LIKE '%umo%' )
OR
( ads_postmeta.meta_key = 'profileLocation' AND ads_postmeta.meta_value LIKE '%umo%' )
OR
( ads_postmeta.meta_key = 'profileBusinessTel' AND ads_postmeta.meta_value LIKE '%umo%' )
) AND ads_posts.post_type = 'profile' AND ((ads_posts.post_status = 'publish'))
GROUP BY ads_posts.IDads_posts.ID ORDER BY RAND()
made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/classifieds/search.php'), WP_Query->__construct, WP_Query->query, WP_Query->get_posts
最好的解决方案是什么?
解决方案
推荐阅读
- ibm-mq - LDAPCONN (INACTIVE):如何成功评估 ldapconn 非活动错误的原因?
- firebase - Admob 中没有“链接到 Firebase”选项
- php - 如何使用 ajax(一个文件)从 php 获取响应数据?
- javascript - 为什么在 componentDidUpdate 中比较数组不会导致无限循环?
- node.js - 需要有一个函数来处理数据库中的所有 CRUD 操作
- sql - 从两个给定列表创建表
- ruby - 将命令('stdout')强制转换为整数以进行数学比较
- python - 代码在最后一次输入时运行,它会关闭窗口,为什么?
- javascript - Intersection Observer 在 ngAfterViewInit 上触发两次回调
- rx-java2 - Micronaut 数据 - 可分页或 Flowable.skip().limit()?