【发布时间】:2016-12-29 13:01:54
【问题描述】:
我为 Wordpress 使用 Timber 插件。
然后我创建了一个结果搜索页面。我想突出显示用户搜索的单词。
我在 PHP 中写道:
$highlight = array();
if ($terms) {
foreach($terms as $term) {
array_push($highlight, '<span class="blue bold">'.$term.'</span>');
}
}
然后,用 PHP 替换搜索到的单词:
<p class="date red"><?php echo str_ireplace($terms, $highlight, get_field('subtitle_post')); ?></p
但我不知道如何在 Twig (Timber) 中转换它?
【问题讨论】: