WordPress 截断标题
我有这个工作...但是。
<?php
$thetitle = $post->post_title; /* or you can use get_the_title() */
$getlength = mb_strlen($thetitle);
$thelength = 25;
echo mb_substr($thetitle, 0, $thelength);
if ($getlength > $thelength) echo "...";
?>
只需说标题是“嘿,你好吗”,它就会在“嘿,”之后将其截断。
我想在逗号之后和结束引用之前删除一个空格。
有办法做到这一点吗?否则标题看起来像:
嘿,...
而不是:
嘿,...
谢谢
I have this working... but.
<?php
$thetitle = $post->post_title; /* or you can use get_the_title() */
$getlength = mb_strlen($thetitle);
$thelength = 25;
echo mb_substr($thetitle, 0, $thelength);
if ($getlength > $thelength) echo "...";
?>
Just say the title is "Hey, how are you" and it truncates it after "Hey, ".
There is a space I want to eliminate after the comma and before the end quote.
Is there a way to do this? Otherwise the title looks like:
Hey, ...
Instead of:
Hey,...
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要修剪空白即可。
you just need to trim the white spaces.