php strstr函数在wordpress tag.php文件中不起作用

php strstr函数在wordpress tag.php文件中不起作用,php,wordpress,Php,Wordpress,我在WordPress theme tag.php文件中添加了以下代码 <?php while ( have_posts() ) : the_post(); $title = strstr(the_title(), '|', true); $link = get_permalink(); echo '<a class="w3-bar-item w3-button" href="'.$

我在WordPress theme tag.php文件中添加了以下代码

<?php
    while ( have_posts() ) :
        the_post();
        $title = strstr(the_title(), '|', true);
        $link = get_permalink();
        echo '<a class="w3-bar-item w3-button" href="'.$link.'" target="_top" rel="noopener noreferrer">'.$title.'</a>';
    endwhile;
?>
PHP strstr函数似乎在此文件中不起作用,并且$title未打印在标记中。
提前感谢

您应该将_标题的第三个参数替换为false:

$title = strstr(the_title(), '|', true);

void |如果$echo参数为true,则字符串void,如果为true,则当前帖子标题为 $echo是假的


来源:

尝试echo$link lonely。标题输出标题。要将标题作为字符串获取,请使用另一个函数。顺便说一句,手册中对此进行了解释。请提供一个。你没有提供所有必要的信息来帮助你。标题中的内容我们不想让你回答一些明显的标题,我们想要一个确切的定义,这个值是多少,非常感谢你。右边的函数是@DefinitelynotRafal,它是一个WordPress函数。这个问题包含了wordpress标签,所以我们可以假设这就是他们所引用的。真/假是strstr的一部分-意思是在针线之前对不起,编辑我的帖子应该是现在
$title = strstr(the_title('','',false), '|', true);