Do you want to remove the author name from your WordPress blog posts? Normally, blog posts are supposed to show author name with other meta-data like date and category.
您是否要从WordPress博客帖子中删除作者姓名? 通常,博客文章应该显示作者姓名以及其他元数据,例如日期和类别。
However, some blog owners may not want to display the author name next to their blog posts.
但是,某些博客所有者可能不希望在其博客文章旁边显示作者姓名。
By default, WordPress does not have an option to remove author name, and you must select an author to publish a post.
默认情况下,WordPress没有选择删除作者姓名的选项,您必须选择一个作者才能发布帖子。
In this article, we will show you two ways to easily remove author name from your WordPress posts. We will also discuss the pros and cons of each approach.
在本文中,我们将向您展示两种轻松地从WordPress帖子中删除作者姓名的方法。 我们还将讨论每种方法的利弊。
为什么要删除作者姓名? (Why Would You Want to Remove Author Name?)
Author name is an important type of metadata added to your WordPress posts by default. It allows your readers to learn about authors who create content on your blog.
作者名称是默认情况下添加到WordPress帖子中的重要元数据类型。 它使您的读者可以了解在您的博客上创建内容的作者。
However, there are times when you may want to hide the author name.
但是,有时您可能想隐藏作者姓名。
For example: if multiple staff members in your team collaborate on each blog post, then it may seem unfair to credit a single staff member for the work.
例如:如果您团队中的多个职员在每个博客帖子上进行协作,那么将单个职员归功于该工作似乎是不公平的。
In another scenario, you may have several contributors/freelance writers who occasionally write articles, but you want to keep a consistent style and voice for your blog.
在另一种情况下,您可能会有几位撰稿人/自由撰稿人偶尔撰写文章,但您希望保持博客的风格和声音一致。
With that said, let’s take a look at solutions for easily removing author name from WordPress posts while still allowing multiple authors to work in the background.
话虽如此,让我们看一下轻松地从WordPress帖子中删除作者姓名,同时仍允许多位作者在后台工作的解决方案。
方法1:从WordPress帖子中手动删除作者姓名 (Method 1: Manually Remove Author Name from WordPress Posts)
Your WordPress theme decides when and how to display the author name in your blog posts. Themes use multiple approaches to do that which makes it harder for a plugin to provide a generic solution for removing author names.
WordPress主题决定何时以及如何在博客文章中显示作者姓名。 主题使用多种方法来执行此操作,这使得插件很难提供用于删除作者姓名的通用解决方案。
You will need to edit some code to prevent your theme from displaying the author name. If you are uncomfortable editing code, then try the second method instead.
您将需要编辑一些代码以防止主题显示作者姓名。 如果您不满意编辑代码,请尝试第二种方法。
The first method requires you to edit WordPress theme files. If you haven’t done this before, then please take a look at our guide on how to copy and paste the code in WordPress.
第一种方法要求您编辑WordPress主题文件。 如果您之前没有做过,请查看我们的指南, 了解如何在WordPress中复制和粘贴代码 。
Note: Make sure that you create backup of your theme or child theme before making any changes. If something goes wrong, then this will help you easily revert changes.
注意:在进行任何更改之前,请确保创建主题或子主题的 备份 。 如果出现问题,这将帮助您轻松地还原更改。
WordPress themes use different variations of code to display the author name. You will need to locate the code responsible for showing the author’s name in your theme files and delete it.
WordPress主题使用不同的代码变体来显示作者姓名。 您将需要找到负责在主题文件中显示作者姓名的代码并将其删除。
Most common locations to find this code are single.php, content.php, archive.php, and index.php files.
查找此代码的最常见位置是single.php,content.php,archive.php和index.php文件。
In many cases, you will not be able to find the code that outputs author name. Instead, you will find a template tag defined in the functions.php file or template-tags.php file.
在许多情况下,您将找不到输出作者姓名的代码。 相反,您会在functions.php文件或template-tags.php文件中找到定义的模板标签。
For example, the default Twenty Nineteen theme uses the function twentynineteen_posted_by
to display author name. This function is defined in template-tags.php file and uses the following code:
例如,默认的“二十十九”主题使用功能二十十九twentynineteen_posted_by
显示作者姓名。 此函数在template-tags.php文件中定义,并使用以下代码:
function twentynineteen_posted_by() {
printf(
/* translators: 1: SVG icon. 2: post author, only visible to screen readers. 3: author link. */
'<span class="byline">%1$s<span class="screen-reader-text">%2$s</span><span class="author vcard"><a class="url fn n" href="%3$s">%4$s</a></span></span>',
twentynineteen_get_icon_svg( 'person', 16 ),
__( 'Posted by', 'twentynineteen' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_html( get_the_author() )
);
}
endif;
Once you have located the code that outputs the author name, you need to delete it.
找到输出作者姓名的代码后,需要将其删除。
For example, you have to delete the code from the second line to the ninth line in the above code. After that, the remaining code will look like below.
例如,您必须删除上面代码中第二行到第九行的代码。 之后,其余代码如下所示。
function twentynineteen_posted_by() {
}
endif;
Don’t forget to save your changes after deleting the author name code. Then, upload the files back to your website.
删除作者姓名代码后,请不要忘记保存更改。 然后,将文件上传回您的网站。
You can now visit your website to see your changes in action:
现在,您可以访问您的网站以查看您所做的更改:
This method hides the author name on all your posts; however, the author archive pages will remain intact. An author archive page is where WordPress creates a list of all articles written by a specific user.
此方法在所有帖子中隐藏作者姓名; 但是,作者存档页面将保持不变。 作者档案页面是WordPress创建特定用户撰写的所有文章的列表的地方。
You can find author archive page on a URL like this:
您可以在如下网址上找到作者档案页面:
https://example.com/author/samsmith/
https://example.com/author/samsmith/
This URL is discoverable by search engines, which means you may still get traffic to those pages.
搜索引擎可以发现此URL,这意味着您仍然可以访问这些页面。
You can disable the author archives easily using the Yoast SEO plugin. Once you install and activate the plugin, go to SEO » Search Appearance your dashboard and then click the ‘Archives’ tab.
您可以使用Yoast SEO插件轻松禁用作者档案。 安装并激活插件后,转到SEO»搜索仪表盘,然后单击“存档”选项卡。
Now you can see the author archive settings. You can toggle Author Archives switch and disable author archives on your site.
现在,您可以看到作者档案设置。 您可以切换“作者档案”开关并禁用站点上的作者档案。
Doing so will disable author archives and hide author-sitemap.xml
file created by the Yoast SEO plugin.
这样做将禁用作者档案,并隐藏Yoast SEO插件创建的author-sitemap.xml
文件。
方法2:创建用于发布WordPress帖子的通用作者名称 (Method 2: Create a Generic Author Name for Publishing WordPress Posts)
This method does not remove the author name, but it can be used as a workaround.
此方法不会删除作者姓名,但是可以将其用作解决方法。
You will create a generic author name and use it for all your past and future articles. You will need to change the author name before publishing each post.
您将创建一个通用的作者名称,并将其用于您过去和将来的所有文章。 在发布每篇文章之前,您需要更改作者姓名。
Note: This method is irreversible. If you do this and want to revert, then you will have to edit each post and assign it to the original author manually.
注意:此方法是不可逆的。 如果执行此操作并想要还原,则必须编辑每个帖子并将其手动分配给原始作者。
That being said, let’s get started.
话虽如此,让我们开始吧。
First add a new author to your WordPress site and give it a generic username such as editorialteam.
首先, 将新作者添加到您的WordPress网站,并为其提供通用用户名,例如Editorialteam。
Next, you need to visit Users » All Users page and click on the ‘Edit’ link below the username you just added.
接下来,您需要访问用户»所有用户页面,然后单击刚添加的用户名下方的“编辑”链接。
On the user profile screen, scroll down to the ‘Nickname’ option and enter the name you want to be displayed (for example, Editorial Team).
在用户个人资料屏幕上,向下滚动到“昵称”选项,然后输入要显示的名称(例如,Editorial Team)。
After that, click on the drop down menu next to ‘Display name publicly as’ option and select the nickname you just entered.
之后,点击“将名称公开显示为”选项旁边的下拉菜单,然后选择您刚刚输入的昵称。
You can also add a generic bio and even create a gravatar for that user account.
Now go to Posts » All Posts page and click on the screen options menu at the top. Enter 999 for number of items to display.
现在转到帖子»所有帖子页面,然后单击顶部的屏幕选项菜单。 输入999作为要显示的项目数。
This will allow you to quickly edit and change author name for a large number of posts.
这将使您可以快速编辑和更改大量帖子的作者姓名。
You need to select all posts using the checkbox and then select edit under the bulk actions drop down menu. After that click on the ‘Apply’ button to continue.
您需要使用复选框选择所有帖子,然后在批量操作下拉菜单下选择编辑。 之后,单击“应用”按钮继续。
WordPress will now show you the bulk editing options. You need to change the author to the generic author name you added earlier and then click on the Update button.
WordPress现在将向您显示批量编辑选项。 您需要将作者更改为之前添加的通用作者名称,然后单击“更新”按钮。
WordPress will now update all selected posts and change author name. Remember, this process may take some time depending on how fast your WordPress hosting is.
WordPress现在将更新所有选中的帖子并更改作者姓名。 请记住,此过程可能需要一些时间,具体取决于您的WordPress托管速度。
If you have more than 999 posts, then you will need to go to page 2 and repeat the process.
如果您有999个以上的帖子,则需要转到第2页并重复该过程。
That’s all. You can now visit your website to see it in action.
就这样。 现在,您可以访问您的网站以查看其运行情况。
我们的建议 (Our Recommendation)
Removing author name using the coding method gets the job done, but it is not the best solution. For example, if you are not using a child theme, then a theme update will override your changes.
使用编码方法删除作者姓名可以完成工作,但这不是最佳解决方案。 例如,如果您不使用子主题,则主题更新将覆盖您的更改。
This is why we recommend the second method to create a generic author name.
这就是为什么我们建议使用第二种方法来创建通用作者名称的原因。
Doing so allows you to use the built-in WordPress functionality and does not require you to edit any code. It will not remove author name or archives but will make them generic. It will also help to ensure consistency of authorship on your site.
这样做可以让您使用内置的WordPress功能,而无需您编辑任何代码。 它不会删除作者姓名或档案,但会使它们通用。 这也将有助于确保您网站上作者身份的一致性。
If you are good with coding, then you can also use a combination of both approaches. You can create a generic author name to publish all your blog posts, and then hard-code author profile in a WordPress child-theme.
如果您擅长编码,则也可以将两种方法结合使用。 您可以创建一个通用的作者姓名来发布所有博客文章,然后在WordPress子主题中硬编码作者个人资料。
We use a similar approach at WPBeginner. You can see ‘Editorial Staff’ as the author for all blog posts including this one you are reading right now.
我们在WPBeginner使用类似的方法。 您可以将“ Editorial Staff”视为所有博客文章的作者,包括您当前正在阅读的这篇文章。
You can also see that in the author info box at the bottom of the article.
您还可以在文章底部的作者信息框中看到该内容。
If you want to add an author info box like this, then take a look at the best free author bio box plugins.
如果要添加这样的作者信息框,请查看最佳的免费作者简介框 。
We hope this article helped you learn how to remove author name from WordPress posts. You may also want to see our list of 30 effective ways to monetize your website.
我们希望本文能帮助您学习如何从WordPress帖子中删除作者姓名。 您可能还希望查看我们的30种有效的网站获利方法列表。
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视频教程。 您也可以在Twitter和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-themes/how-to-remove-author-name-from-wordpress-posts/