如何在WordPress摘录中显示更多阅读链接

To prevent duplicate content, improve site load time, and for better SEO many bloggers have started to use post excerpts. Excerpts are mini-descriptions of the posts shown on the main blog page, category pages, and archive pages. You can see a live example by visiting any of our categories. But if you notice, our read more button is added on a separate line from the excerpt text. In this article, we will show you how to automatically add a read more link in WordPress Excerpts.

为了防止重复的内容,缩短网站加载时间,并且为了获得更好的SEO,许多博客作者已开始使用后摘录。 摘录是博客主页面,类别页面和存档页面上显示的帖子的迷你描述。 您可以通过访问我们的任何类别来查看实时示例。 但是,如果您注意到,我们的“阅读更多”按钮将添加到摘录文本的另一行。 在本文中,我们将向您展示如何在WordPress摘录中自动添加更多阅读链接。

First open your functions.php file, and paste the following code inside the php tags:

首先打开您的functions.php文件,然后将以下代码粘贴到php标签中:

 // Changing excerpt more
    function new_excerpt_more($more) {
    global $post;
    return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

In this function, you are telling WordPress to remove the default more which looks like this: […], and replace it with a link. This short and simple tutorial was requested via our suggestion form. You can suggest article ideas as well by using our suggestion form or our twitter @wpbeginner.

在此功能中,您要告诉WordPress删除如下所示的更多默认值:[…],然后将其替换为链接。 通过我们的建议表要求了这个简短的教程。 您也可以使用我们的建议表或我们的Twitter @wpbeginner来建议文章想法。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-display-a-read-more-link-in-wordpress-excerpts/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值