0

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

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

the_title()当我将鼠标悬停在它上面时,它会在 Eclipse 中显示以下功能:

function = the_title($before = '', $after = '', $echo = true){
    $title = get_the_title();

    if (strlen($title) == 0 )
        return
    $title = $before . $title . $after

    if ($echo)
        echo $title;

    else
        ...

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

4

1 回答 1

2

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

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

您不必将标题存储在变量中,您可以直接转到:

$substr = substr(get_the_title(), -1);
于 2012-08-31T17:15:36.560 回答