wordpress中有没有一种本地方式可以将scentence /的第一个单词的第一个字母变成大写标题 http://codex.wordpress.org/Function_Reference/the_title帖子的?
如果没有,我该如何在 php 中做到这一点,而它被包装在<a></a>
tag?
这是完整的代码行。
<a href="<?php the_permalink(); ?>"><?php ucfirst(the_title());?></a>
正如你所看到的,我已经尝试过ucfirst https://www.php.net/ucfirst,但它不起作用。我尝试的另一件事是:
<?php
$temp_title = the_title();
$final_title = ucfirst($temp_title);
?>
<a href="<?php the_permalink(); ?>"><?php echo $final_title;?></a>
ucfirst()
返回一个字符串。你需要echo
返回值ucfirst()
.
此外,WordPress功能the_title()
直接打印标题,而不是将其作为字符串返回。使用get_the_title() http://codex.wordpress.org/Function_Reference/get_the_title反而。
<a href="<?php the_permalink(); ?>"><?php echo ucfirst(get_the_title());?></a>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)