wordpress 自定义_如何自定义WordPress摘录(无需编码)

wordpress 自定义

Do you want to customize your WordPress excerpt? Not sure what is a WordPress excerpt? Don’t worry. In this article, we will show you how to customize WordPress excerpts (no coding required).

您要自定义WordPress摘录吗? 不确定什么是WordPress摘录? 不用担心 在本文中,我们将向您展示如何自定义WordPress摘录(无需编码)。

Excerpts are the short extract from your post. WordPress comes with a built-in function which make it easier for you to decide what you want to show as the excerpt for your post.

摘录是您帖子的简短摘录。 WordPress带有内置功能,使您可以更轻松地决定要显示为帖子摘录的内容。

Custom Excerpt
何时何地应该使用节选 (When and Why You Should Use Excerpts)

First let’s talk about why you should use excerpts on your WordPress blog instead of full articles.

首先让我们谈谈为什么应该在WordPress博客上使用摘录而不是全文。

By default, WordPress shows full posts on the homepage, blog page, and archives of your site. This makes your site slower and could lead search engines to believe that all these pages have duplicate content.

默认情况下,WordPress在网站的首页 ,博客页面和存档中显示完整的帖子。 这会使您的网站变慢,并使搜索引擎认为所有这些页面都有重复的内容。

Using excerpts will load your pages faster because you will only be loading a small part of each article, and your archive pages won’t get hit with a duplicate content penalty.

使用摘录可以更快地加载页面,因为您只会加载每篇文章的一小部分,并且存档页面不会因重复的内容而受到损失。

See our article on Full Posts vs Excerpts, for more detailed discussion on the topic.

有关该主题的详细讨论,请参见我们的文章Fulls vs Excerpts

Some WordPress themes are configured to automatically create a short excerpt of your posts even if you didn’t add one. The disadvantage of this method is that your theme calculates the excerpt for you, and it may not look good.

某些WordPress主题配置为自动创建您的帖子的简短摘录,即使您没有添加这些主题。 这种方法的缺点是您的主题会为您计算摘录,而且看起来可能不太好。

That’s why you may want to create a custom excerpt. Let’s take a look at 3 different ways you can add custom excerpts in WordPress.

这就是为什么您可能要创建一个自定义摘录的原因。 让我们看一下可以在WordPress中添加自定义摘录的3种不同方式。

影片教学 (Video Tutorial)

演示地址

If you don’t like the video or need more instructions, then continue reading.

如果您不喜欢该视频或需要更多说明,请继续阅读。

1.如何在WordPress中添加自定义摘录(默认) (1. How to Add a Custom Excerpt in WordPress (Default))

Adding a custom excerpt in WordPress is quite simple. Create a new post or edit an existing one.

在WordPress中添加自定义摘录非常简单。 创建一个新帖子或编辑一个现有的帖子。

On the post edit screen, click on the screen options tab on the top right and then select excerpt.

在帖子编辑屏幕上,单击右上角的屏幕选项选项卡,然后选择摘录。

Showing excerpt option on post edit screen

This will display an excerpt meta box below your post editor. You can now add any text in this box, and it will be used as the excerpt for the post.

这将在您的帖子编辑器下方显示一个摘录元框。 现在,您可以在此框中添加任何文本,它将用作帖子的摘录。

Excerpt meta box where you can add a custom excerpt for your WordPress post

The problem you will now face is that some themes will not show your custom excerpt. For those, you will have to edit your theme files particularly home.php, content.php, archive.php, category.php, etc. You will need to locate:

您现在将面临的问题是某些主题不会显示您的自定义摘录。 对于这些,您将必须编辑主题文件,尤其是home.php,content.php,archive.php,category.php等。您需要找到:

<?php the_content(); ?>

<?php the_content(); ?>

Next, you will need to replace it with the_excerpt tag like this:

接下来,您将需要用the​​_excerpt标记替换它,如下所示:

<?php the_excerpt(); ?>

<?php the_excerpt(); ?>

This is not an ideal solution for beginners who do not want to edit their theme files. That’s when the next method comes in handy.

对于不想编辑主题文件的初学者来说,这不是理想的解决方案。 这就是下一种方法派上用场的时候。

2.添加带有更多标签的摘录 (2. Adding an Excerpt with The More Tag)

Another way to add excerpt to your WordPress homepage and archive pages is by using the more tag.

将摘录添加到WordPress主页和存档页面的另一种方法是使用more标记。

You can add the more tag by placing your cursor in the post editor to the point where you want to break the post and then click on the more button.

您可以通过将光标置于帖子编辑器中要中断帖子的位置,然后单击“更多”按钮来添加更多标签。

Gif showing the usage of more button in WordPress post editor

See our tutorial on how to properly use the more tag in WordPress for detailed instructions.

有关详细说明,请参阅我们的教程, 了解如何在WordPress中正确使用more标记

Most themes will be properly configured to display the more tag. However if yours isn’t, then don’t worry. There is another way.

大多数主题将被正确配置为显示更多标签。 但是,如果您的不在,那就不用担心。 还有另一种方法。

3.使用插件添加自定义摘录 (3. Adding Custom Excerpts Using Plugin)

If the first two methods don’t work with your WordPress theme, then here is how you can take the custom excerpts to a whole new level without writing any code.

如果前两种方法不适用于您的WordPress主题,那么您可以在不编写任何代码的情况下将自定义摘录提升到一个全新的水平。

First thing you need to do is install and activate the Advanced Excerpt plugin. Upon activation, you need to visit Settings » Excerpt page to configure the plugin.

您需要做的第一件事是安装并激活Advanced Excerpt插件。 激活后,您需要访问设置»摘录页面来配置插件。

Advanced excerpt options

Advanced Excerpt plugin allows you to solve the excerpt display issues caused by your theme. You can set up an excerpt as well as define how and where you want it to appear.

高级摘录插件可让您解决由主题引起的摘录显示问题。 您可以设置摘录以及定义其显示方式和位置。

It is also a lot easier to use, and you will not have to modify any theme files.

它也易于使用,并且您无需修改​​任何主题文件。

Some of the features of Advanced Excerpt plugin:

Advanced Excerpt插件的一些功能:

  • You can define custom excerpt length.

    您可以定义自定义摘录长度。
  • You can avoid incomplete words or sentences in excerpt.

    您可以避免摘录中的单词或句子不完整。
  • Choose what to show at the end of the excerpt.

    选择摘要结尾处显示的内容。
  • Add a custom excerpt read more link.

    添加自定义摘录,以获取更多链接。
  • Override custom defined excerpts.

    覆盖自定义定义的摘录。
  • Enable or disable excerpts on home, arhive, category, tag, etc.

    启用或禁用家庭,档案,类别,标签等摘要。
  • You can allow HTML to be parsed in excerpt.

    您可以允许摘录中分析HTML。
  • You can skip or allow shortcodes to be executed in excerpt.

    您可以跳过或允许摘录中执行短代码。

Once you are done setting up your excerpt, click on the save changes button to store your settings. You can now visit your website to see the excerpts in action.

完成摘录的设置后,单击“保存更改”按钮以存储您的设置。 现在,您可以访问您的网站以查看摘录。

Advanced Excerpt does not make any changes to your posts content. If you ever want to use something else or use your theme’s excerpts, then you can just deactivate the plugin.

高级摘录不会对您的帖子内容进行任何更改。 如果您想使用其他东西或使用主题摘录,则只需停用插件即可。

We hope this article helped you customize WordPress excerpts without any coding. You may also want to see our tutorial on how to add tables in WordPress posts and pages (no HTML required).

我们希望本文能帮助您自定义WordPress摘录,而无需任何编码。 您可能还想看一下有关如何在WordPress帖子和页面中添加表格的教程(无需HTML)。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/plugins/how-to-customize-wordpress-excerpts-no-coding-required/

wordpress 自定义

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值