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.
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.
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:
1 2 3 4 | /* 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.