这是一个骗局。
在要搜索奇怪字符串的字母前加前缀:
$letter = \'§§§\' . \'a\'; // strange string plus the letter you want to search
然后将筛选器应用于
terms_clauses
挂钩:
add_filter(\'terms_clauses\', \'replace_name__like_for_ingredients\', 10, 3);
$terms = get_terms( "ingredient", array( \'name__like\' => $letter ) );
最后使用该函数删除
%
在奇怪字符串和奇怪字符串本身之前:
function replace_name__like_for_ingredient( $pieces, $taxonomies, $args ) {
if ( in_array(\'ingredient\', $taxonomies) ) {
// replace the perc sign plus strange string with empty string so
// LIKE \'%§§§a%\' become LIKE \'a%\'
$pieces[\'where\'] = str_replace("%§§§", \'\', $pieces[\'where\']);
}
return $pieces;
}
Untested.