url wordpress_如何从WordPress URL中删除数字

url wordpress

Recently one of our readers emailed us asking the question how to get rid of numbers from WordPress post and page URLs. By default, WordPress uses post IDs (numbers) instead of pretty keyword text in the URLs. This is bad for SEO. In other cases, WordPress will add a -2 in front of your post, page, category, or tag URLs which simply looks bad in front of users. In this article, we will show you how to get rid of numbers from WordPress URLs.

最近,我们的一位读者通过电子邮件向我们询问了如何消除WordPress帖子和页面URL中的数字的问题。 默认情况下,WordPress使用帖子ID(数字)代替URL中的漂亮关键字文本。 这对SEO不利。 在其他情况下,WordPress会在您的帖子,页面,类别或标签URL前面添加-2,这在用户面前看起来很糟糕。 在本文中,我们将向您展示如何摆脱WordPress URL中的数字。

影片教学 (Video Tutorial)

演示地址

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

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

永久链接URL结构 (Permalink URL Structure)

WordPress has built in support for SEO friendly URL structure. All you need to do is to open Settings » Permalinks page in the admin area and choose a URL structure for your site. There are a number of options available. We recommend choosing a URL structure that shows your post title in the URL because it is SEO friendly and will help others discover your site in search engines. Once you have setup permalinks you need to save your changes.

WordPress内置了对SEO友好URL结构的支持。 您所需要做的就是在管理区域中打开“设置”»“永久链接”页面,然后为您的网站选择一个URL结构。 有许多可用的选项。 我们建议选择一种URL结构,以在URL中显示您的帖子标题,因为它对SEO友好,并且可以帮助其他人在搜索引擎中发现您的网站。 设置永久链接后,您需要保存更改。

Setting up permalinks in WordPress

WordPress will now automatically change URLs for all your previous posts as well. Don’t worry if you have posted the older URLs somewhere because WordPress will automatically redirect those users to new URLs.

WordPress现在还将自动更改您以前所有帖子的URL。 如果您将较旧的URL发布到某个地方,请不要担心,因为WordPress会自动将这些用户重定向到新URL。

自定义子弹 (Custom Slug)

Even though you are using Pretty Permalinks now, you may still want to get rid of numbers in your post URL. The most common reason for this is when you are publishing a post that has no title.

即使您现在正在使用Pretty Permalinks,您仍可能希望删除帖子URL中的数字。 最常见的原因是在发布无标题的帖子时。

Remember, WordPress chooses the text to display in URL from your post’s title, so if your post does not have a title, then WordPress will use the post’s ID in the URL. You can manually tell WordPress what to use in the URL instead of the post number.

请记住,WordPress从帖子标题中选择要显示在URL中的文本,因此,如果您的帖子没有标题,则WordPress将在URL中使用帖子的ID。 您可以手动告诉WordPress在URL中使用什么而不是帖子号。

Just below the post title, you will see your post’s URL with an Edit button next to it. Clicking on the edit button will make the URL editable. This editable part is called post-slug. You can enter the text you want to use as post slug in the URL.

在帖子标题的正下方,您将看到帖子的URL,旁边是“编辑”按钮。 单击编辑按钮将使URL可编辑。 此可编辑部分称为子弹后。 您可以在URL中输入要用作帖子的文字。

Note: you can only add letters, numbers, and dashes in the URL slug.

注意:您只能在网址段中添加字母,数字和破折号。

Editing post slug in WordPress
帖子和页面重复 (Duplicate Posts and Pages)

Sometimes even when you edit the custom slug, the -2 continues to be added in your URLs. For example you create a new about page, and your URL looks like this:

有时,即使您编辑自定义子词,-2仍会继续添加到您的URL中。 例如,您创建一个新的关于页面,您的URL如下所示:

http://yoursite.com/about-2/

http://yoursite.com/about-2/

Now wouldn’t you want to get rid of that -2, and simply have it as /about/. This problem occurs when you have the same slug being used already.

现在,您是否不想摆脱该-2,而只需将其作为/ about /。 当您已经使用了相同的块时,会发生此问题。

Check all your posts and pages to see that there is none that has the same slug (i.e /about/). If you find one, then you need to delete it unless you’re using it. More often than not, you won’t find an active page with the same slug.

检查您所有的帖子和页面,以查看没有任何帖子和帖子具有相同的标记(即/ about /)。 如果找到一个,则除非使用它,否则需要将其删除。 通常,您不会找到带有相同标签的活动页面。

This is when you need to look in the Trash folder. When you trash a WordPress post or page, it is not entirely deleted. It sits in the trash for 30 days before it gets permanently deleted. This is done to give you an option to restore trashed item if you accidentally deleted them.

这是您需要在“垃圾箱”文件夹中查找的时候。 当您丢弃WordPress帖子或页面时,它不会被完全删除。 它在垃圾箱中放置了30天,然后被永久删除。 这样做是为了让您有一个选择,如果您不小心删除了已删除的邮件,则可以将其还原。

As long as the post or page stays in the trash, the slug cannot be re-used. So if you want to re-use the /about/ slug, then you must delete the About page sitting in the trash folder. Once you do that, you should be able to edit your slug like the method shown above and get rid of the -2.

只要帖子或页面停留在垃圾桶中,就不能重复使用该弹头。 因此,如果要重复使用/ about /插件,则必须删除垃圾箱文件夹中的“关于”页面。 完成此操作后,您应该能够像上面显示的方法一样编辑子弹,并摆脱-2。

This technique works for categories and tags as well.

该技术也适用于类别和标签。

We hope this article helped you get rid of numbers from WordPress URLs. For feedback and questions, you can leave your comments below or join us on Twitter and Google+

我们希望本文能帮助您摆脱WordPress URL中的数字。 有关反馈和问题,您可以在下面留下您的评论,或者在TwitterGoogle+上加入我们

翻译自: https://www.wpbeginner.com/beginners-guide/how-to-remove-numbers-from-wordpress-urls/

url wordpress

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值