您需要正则表达式来实现这一点。
首先,你需要改变\'LIKE\' 到\'RLIKE\' (或\'REGEXP\').
第二,更换$keyword 在里面\'value\' 使用涉及单词边界的正则表达式。
像这样:
$queryArgs = array(
\'post_type\' => \'faculty\',
\'posts_per_page\' => -1,
\'meta_query\' => array(
\'relation\' => \'OR\',
array(
\'key\' => \'proposed_keywords\', // name of custom field
\'value\' => "[[:<:]]$keyword[[:>:]]", // matches exaclty "123", not just 123. This prevents a match for "1234"
\'compare\' => \'RLIKE\'
)
)
);