如何在wordpress中获取帖子标题的第一个字母 [英] How to get the first letter of a post title in wordpress
本文介绍了如何在wordpress中获取帖子标题的第一个字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 wordpress 中获取帖子标题的第一个字母,然后在其上使用 substr
以使用此代码段获取第一个字母,但它仍然显示完整的单词.
I want to get the first letter of a post title in wordpress, then use substr
on it to get the first letter by using this snippet but it still displays the full word.
<?php
$get_title = the_title();
$ltr_group = mb_substr($get_title, 0, 1);
echo $ltr_group;
?>
推荐答案
请试试这个可能对你有用的代码:
Please try this code maybe useful for you:
<?php
$get_title = get_the_title();
$ltr_group = substr($get_title, 0, 1);
echo $ltr_group;
?>
这篇关于如何在wordpress中获取帖子标题的第一个字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文