问题描述
有一个模板https://wordpress.org/themes/bizberg/。
在“自定义”中,滑块标题类型是可调的,并且标题的第一个单词颜色可以替换为主题颜色。 但是没有必要在句子“世界是美丽的”的“ the”文章上设置不同的颜色。至少应该是前两个词:“未来”,“世界”等。
任何想法如何进行?
提前谢谢!
(下面是php代码)
functions.php:
return '<h1 class="slider_title_layout_' . $slider_title_layout . ' ' . $slider_text_align . '">' . '<span class="firstword">'.$title[0].'</span>'.substr(implode(" ",$title),strlen($title[0])) . '</h1>';
front-page-hero.php:
array(
'element' => '.slider_title_layout_3 .firstword,.slider_title_layout_4 .lastword','property' => 'color'
),
解决方法
感谢 @CBroe 的提示!
”将$ title [0]的两个出现都替换为$ title [0]。” '。$ title [1]。”
效果很好!
我也收到了来自 @Sergei Kirjanov 的完美答复。
因此,如果您只需要在某些幻灯片中突出显示几个标题词,请在必要的词后加上“ ^”符号,并更改php代码:
$title = explode( strpos($title,"^") ? "^" : " ",$title );
它说,如果字符串中有“ ^”,则将彩色标题部分分开,否则通常在空格“”之后。