首页 > 新闻资讯 > 用WordPress过滤器替换"read more"字样

用WordPress过滤器替换"read more"字样

1条评论
标签:
更多

"read more"是个好东西,方便你把长文章截断,保持主页的整洁。但问题是你无法替换"read more"的文字。下面告诉你替换的方法。

老样子,打开function.php,插入以下代码:

<?php

$custom_more = "Continue reading this post"; //替换后的文字
add_filter( 'the_content_more_link', 'my_more_link', 10, 2 );

function my_more_link( $more_link, $more_link_text ) {
return str_replace( $more_link_text, $custom_more, $more_link );
}
?>

大功告成!

* 版权声明:作者WordPress啦! 转载请注明出处。

#1
喜欢直接修改主题模板。

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.