我的客户正在使用Divi构建器主题,并要求我在分类存档页面的帖子标题下插入一个子标题。 该主题使用the_content()将所有内容拉入页面,因此仅在页面模板中的标题下添加一行不是一个选项。
这可能不是最好的方法,但我使用ACF来添加get_field(“region”)并修改了这个github中的代码。 它在我需要的地方插入字段,但标题是将html作为文本读取。 我现在有一个<br/>在那里,但想用<span class="">替换。 任何想法为什么它不被视为代码?
现场示例>
码:
function gp121028_filter_title( $title ) { $substrings = explode( ' | ', $title ); $title = ( ! empty( $substrings[0] ) ) ? $substrings[0] . '<br/>' . get_field( "region" ) : $title; return $title;}
My client is using the Divi builder theme and has asked me to insert a subhead under the post title on category archive pages. The theme uses the_content() to pull all content into the pages so simply adding a line under the title in the page templates isn't an option.
This may not be the best way to do it, but I used ACF to add get_field( "region" ) and modified the code from this github. It's inserting the field where I need it, but the title is reading html as text. I have a <br/> in there now but would like to replace with <span class="">. Any idea why it's not being read as code?
live example >
Code:
function gp121028_filter_title( $title ) { $substrings = explode( ' | ', $title ); $title = ( ! empty( $substrings[0] ) ) ? $substrings[0] . '<br/>' . get_field( "region" ) : $title; return $title;}
最满意答案
没有能力解决它 - 建立它manualy。
Wasnt able to solve it - built it manualy.
更多推荐
标题,title,使用,电脑培训,计算机培训,IT培训"/> <meta name="description"
发布评论