正在将substr()添加到<;?php_title()&燃气轮机;

正在将substr()添加到<;?php_title()&燃气轮机;,php,wordpress,Php,Wordpress,我找到了一些关于将substr()添加到变量而不是函数的教程。到目前为止,html的输出是: <div class="symbol"><?php the_title();?></h3> 我只是不确定是否需要添加到后端页面中的函数,或者可以在前端对其进行编码。您可以使用wordpress中的函数获取标题()获取以字符串形式返回的当前标题: $title = get_the_title(); $title_substr = substr($title, -1)

我找到了一些关于将substr()添加到变量而不是函数的教程。到目前为止,html的输出是:

<div class="symbol"><?php the_title();?></h3> 

我只是不确定是否需要添加到后端页面中的函数,或者可以在前端对其进行编码。

您可以使用wordpress中的函数
获取标题()
获取以字符串形式返回的当前标题:

$title = get_the_title();
$title_substr = substr($title, -1);
您不必将标题存储在变量中,只需直接转到:

$substr = substr(get_the_title(), -1);

让php查找最接近的已完成单词(限制12个字符)(上面的代码)
$substr = substr(get_the_title(), -1);