wordpress生成静态_WordPress中用户生成的内容变得容易

wordpress生成静态

There’s probably been a time when you wanted to easily enable your users to to post content on your website. Perhaps, you want to let your users submit their own testimonials. If this is something you’ve been wondering about, you’ve come to the right place. In this tutorial, we’ll walk you through the process of letting users easily add user generated content in WordPress.

可能曾经有一段时间,您希望轻松地使用户能够在您的网站上发布内容。 也许,您想让您的用户提交自己的推荐。 如果这是您一直想知道的事情,那么您来对地方了。 在本教程中,我们将引导您完成让用户轻松在WordPress中添加用户生成的内容的过程。

There are two ways in which you can let your users add custom posts to your site. Firstly, you can let them register on your site and let them manage posts the usual way anyone would in the WordPress dashboard. A second way, is to let unregistered users add guest posts, which can be done through a plugin as explained later in this article.

您可以通过两种方式让用户向您的网站添加自定义帖子。 首先,您可以让他们在您的网站上注册,并让他们以任何人在WordPress仪表板中惯用的方式管理帖子。 第二种方法是让未注册的用户添加来宾帖子,这可以通过插件完成,如本文后面所述。

新注册用户的帖子 (Posts from New Registered Users)

When you first install WordPress, you need to register the Administrator user. However, that is not the only user that can register and access your WordPress site. The core structure of WordPress allows multiple users to register in your using the built-in roles. But, this doesn’t come enabled by default. To turn on the setting to let others register on your site, go to Settings > General and check the ‘Anyone can register’ option.

首次安装WordPress时,您需要注册Administrator用户。 但是,这不是唯一可以注册和访问WordPress网站的用户。 WordPress的核心结构允许多个用户使用内置角色进行注册。 但是,默认情况下未启用此功能。 要打开该设置以允许其他人在您的网站上注册,请转至设置>常规,然后选中“任何人都可以注册”选项。

Enabling the Registration Options

From this moment onwards, a register option will appear on your WordPress login screen, which is shown below.

从这一刻起,注册选项将出现在您的WordPress登录屏幕上,如下所示。

User Login Screen

Alternatively, if you do not want the general public to register, just a few selected users, you can login as the Admin user and create new users yourself under Users > Add New.

另外,如果您不想让公众注册,只需几个选定的用户,您就可以以Admin用户身份登录,并在Users> Add New下自己创建新用户。

Once you have enabled the registration feature, you can let your readers know by adding a widget to the sidebar. You can do that by creating a Meta widget to your sidebar. Go to Appearance > Widgets and drag the Meta widget to your sidebar, or adding a ‘Login/Register’ link manually to the sidebar to the top of the page.

启用注册功能后,可以通过在侧边栏中添加小部件来让读者知道。 您可以通过在边栏上创建一个Meta小部件来做到这一点。 转到外观>窗口小部件,然后将元窗口小部件拖动到侧边栏,或者将“登录/注册”链接手动添加到页面顶部的侧边栏。

Login Meta

Once a user registers on your website, or you manually create an account, the user will be able to log into your site. After logging in, they will be able to create, edit and publish posts and pages, depending on their user role.

用户在您的网站上注册或手动创建帐户后,该用户便可以登录到您的网站。 登录后,他们将能够创建,编辑和发布帖子和页面,具体取决于他们的用户角色。

In short, a Contributor can add and edit posts, but cannot publish them. Authors can add, edit and even publish their own posts. An Editor has all the capabilities of an Author, in addition to the ability to edit and publish posts of others. Here’s a list of user roles and their capabilities.

简而言之,贡献者可以添加和编辑帖子,但不能发布它们。 作者可以添加,编辑甚至发布自己的帖子。 编辑者除了具有编辑和发布他人帖子的功能外,还具有作者的所有功能。 这是用户角色及其功能的列表

Many websites like the popular Sportskeeda use wrappers around the basic WordPress functionality, but the basic idea remains pretty simple. Users are registered as Contributors and can post their articles for moderation, which then go live when approved by an Editor.

许多网站,例如流行的Sportskeeda,都使用围绕WordPress基本功能的包装器,但基本思想仍然非常简单。 用户已注册为贡献者,可以发布其文章进行审核,然后在获得编辑批准后发布。

未注册用户的帖子–用户提交的帖子 (Posts from Unregistered Users – User Submitted Posts)

插件概述 (Plugin Overview)

If you want the ability to accept guest posts or other user generated content without new users needing to register with your site, you will have to use a plugin. There are many plugins that enable users to post content to your site to be published after moderation. However, for this purpose, we’re going to use the plugin User Submitted Posts for its simplicity; it allows users to submit a post via a form, which gets added as pending posts to be moderated.

如果您希望能够接受来宾帖子或其他用户生成的内容,而无需新用户注册您的网站,则必须使用插件。 有许多插件可以使用户将内容发布到您的网站上,以便在审核后发布。 但是,为此,我们将使用插件“ 用户提交的帖子”以简化操作。 它允许用户通过表单提交帖子,该表单将添加为待审核的待审核帖子。

After installing and activating the plugin, you can modify its settings. To do so, go to Settings > User Submitted Posts. Once in the settings page, the overview explains how you should use the plugin. Under Options on that page, you can configure which fields you want to show to your users. You can also set pre-defined settings for incoming posts like auto publishing and attaching categories, assigned author, moderation level, email alerts, enabling the rich text editor, redirect URL and success/error messages.

安装并激活插件后,您可以修改其设置。 为此,请转到设置>用户提交的帖子 。 进入设置页面后,概述将说明您应如何使用插件。 在该页面上的“选项”下,您可以配置要向用户显示的字段。 您还可以为传入的帖子设置预定义的设置,例如自动发布和附加类别,指定的作者,审核级别,电子邮件警报,启用RTF编辑器,重定向URL和成功/错误消息。

Settings of User Submitted Posts Plugin

将表单附加到帖子或页面 (Attaching the Form to a Post or Page)

To display the form on any post or page, you are required to use the following shortcode at the appropriate place.

要在任何帖子或页面上显示表单,您需要在适当的位置使用以下短代码

[user-submitted-posts]

Additionally, you can use the form in a widget, but displaying such a form on every page of your website may not be a wise idea.

此外,您可以在小部件中使用该表单,但是在您网站的每个页面上显示这样的表单可能不是一个明智的主意。

You can also use the following PHP code in your theme to display the form.

您还可以在主题中使用以下PHP代码显示表单。

<?php
    if (function_exists('user_submitted_posts')) user_submitted_posts();
?>

Once you’re done, this is what your form will look like.

完成后,这就是表格的外观。

User Submitted Posts Form

审核用户提交的帖子 (Moderating User Submitted Posts)

Once a user has added a post, you’ll then see it in the pending posts section under Posts > All Posts. You can head over to the post, edit it if you like and publish it as you see fit.

用户添加帖子后,您将在“ 帖子”>“所有帖子”下的“待处理帖子”部分中看到该帖子 。 您可以转到该帖子,根据需要对其进行编辑,然后根据需要发布。

Post Moderation View

Ideally, you should assign a category and an author to all such incoming posts to make sure they’re not confused with your existing posts.

理想情况下,您应该为所有此类传入帖子分配类别和作者,以确保它们不会与您现有的帖子混淆。

宣布新功能 (Announcing the New Feature)

One drawback in this plugin is that it doesn’t come with a built-in widget. However, you can add a widget by using the shortcode attached to this plugin. To do so, go to Appearance > Widgets, and add a ‘Text’ widget with the shortcode for the form as the content of the widget and an appropriate title. You’ll be able to view the same form as a widget.

该插件的一个缺点是它没有内置的小部件。 但是,您可以使用此插件附带的简码添加小部件。 为此,请转到外观>窗口小部件,然后添加带有该表单的短代码的“文本”窗口小部件,作为窗口小部件的内容和适当的标题。 您将能够查看与小部件相同的表单。

This process, however, is not efficient as it loads the form in every single page of your blog, which might affect the loading time of your site, putting more load on your server. Hence, the best way to do this might be to add the form using the shortcode in a separate page and then put the link for the page on the sidebar.

但是,此过程效率不高,因为它会在博客的每个页面中加载表单,这可能会影响网站的加载时间,从而给服务器增加负载。 因此,执行此操作的最佳方法可能是使用简码在单独的页面中添加表单,然后将该页面的链接放在侧边栏上。

结论 (Conclusion)

Did we help you in engaging with your users by allowing them to submit posts to your website? Are there more efficient ways of doing so? Do let us know in the comments below.

我们是否通过允许用户向您的网站提交帖子来帮助您与用户互动? 有更有效的方法吗? 请在下面的评论中告诉我们。

翻译自: https://www.sitepoint.com/user-generated-content-in-wordpress-made-easy/

wordpress生成静态

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值