我按作者的姓首字母筛选帖子。在我的本地服务器上,查询运行得很好,但当我推live时,它没有。它没有找到任何东西。这与我转义自定义字段值的方式有关吗?
$author = get_query_var(\'author-initials\');
if (!empty($author)) {
$initials = explode(\'-\', $author);
$value = array();
foreach($initials as $initial) {
$value[] = strtolower($initial);
$value[] = strtoupper($initial);
}
$meta_query[] = array(
\'key\' => \'whitepaper_author\',
\'value\' => "\\s[" . implode(\'\', $value) . "]\\w+$",
\'compare\' => \'REGEXP\'
);
}
if (count($meta_query) > 1) {
$meta_query[\'relation\'] = \'OR\';
}
$query->set(\'meta_query\', $meta_query);