如何在WordPress中向用户显示上次访问的帖子

Did you ever wonder how websites like Amazon show you recently viewed items even when you are not logged in? Most online shopping sites use cookies to display recently viewed items to their users. This helps users review their options, compare products, and revisit items they liked. In this article we will show you how to display last visited posts to a user in WordPress. The goal is to keep users interested, remind them of usefulness of your website and build brand recognition.

您是否曾经想过像Amazon这样的网站如何显示即使您未登录也最近浏览过的商品? 大多数在线购物网站都使用Cookie向其用户显示最近查看的商品。 这可以帮助用户查看他们的选项,比较产品并重新访问他们喜欢的项目。 在本文中,我们将向您展示如何向WordPress中的用户显示上次访问的帖子。 目的是让用户保持兴趣,提醒他们您的网站有用,并建立品牌知名度。

First thing you need to do is to install and activate the Last Viewed Posts plugin. After activating the plugin, go to Appearance » Widgets. Drag and drop Last Viewed Posts widget to your sidebar and it will immediately start showing posts a user last viewed.

您需要做的第一件事是安装并激活“ 最近查看的帖子”插件。 激活插件后,转到外观»小部件 。 将“ 上次查看的帖子”小部件拖放到侧栏中,它将立即开始显示用户上次查看的帖子。

Last viewed posts widget

This plugin uses cookies to keep track of posts a user has viewed on your website. This cookie expires in 360 days, but you can change that by editing the code. Go to Plugins » Editor and select Last Viewed Posts from plugin edit drop down. Find the parameters and edit them to suit your needs:

该插件使用cookie来跟踪用户在您的网站上查看过的帖子。 该Cookie会在360天后过期,但是您可以通过修改代码来更改它。 转到插件»编辑器,然后从插件编辑下拉菜单中选择上次查看的帖子 。 查找并编辑参数以适合您的需求:


/* Here are some parameters you may want to change: */
$zg_cookie_expire = 360; // After how many days should the cookie expire? Default is 360.
$zg_number_of_posts = 10; // How many posts should be displayed in the list? Default is 10.
$zg_recognize_pages = true; // Should pages to be recognized and listed? Default is true.

We would recommend 60 days for cookie expiration, and 5 posts to be displayed in the list. If you just want to show the last visited post then set the number of posts to 1. It is also advised that you inform users about cookie usage on your site in your privacy policy page. We hope that this article helps you build a loyal user base. For question and feedback please leave a comment.

我们建议cookie的有效期为60天,并在列表中显示5条帖子。 如果您只想显示上次访问的帖子,则将帖子的数量设置为1。建议您在隐私策略页中告知用户网站上Cookie的使用情况。 我们希望本文能帮助您建立忠实的用户群。 对于问题和反馈,请发表评论。

翻译自: https://www.wpbeginner.com/plugins/show-last-visited-post-wordpress/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值