我是业余自学成才的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
什么是最好的解决方案?