Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Display Last Visited Posts to a User in WordPress

Would you like to show your visitors the last blog posts that they viewed?

Many online shopping sites use cookies to display recently viewed items to their users. This helps keep users interested and builds brand recognition. You can do the same thing with the blog posts on your WordPress site.

In this article, we’ll show you how to display the last visited posts to a user in WordPress.

How to Display Last Visited Posts to a User in WordPress

Why Display Last Visited Posts in WordPress?

Visitors to your WordPress blog will often be looking for your latest posts. Making it easy to find fresh content will improve user experience and increase page views. That’s why we usually recommend that you display your recent posts and most popular posts.

However, your users may sometimes come back to your blog to revisit a post they have already read. Websites like Amazon realize this and show visitors recently viewed items to boost sales and increase user engagement.

They use cookies so they can display recently viewed items even when their users are not logged in.

You can do the same thing on your WordPress blog, helping your returning visitors to continue where they left off on their last visit.

Let’s have a look at how you can display a personalized list of the last posts that were visited by a user in WordPress.

How to Display Last Visited Posts in WordPress

The first thing you need to do is to install and activate the Last Viewed Posts plugin. For more details, see our step by step guide on how to install a WordPress plugin.

After activating the plugin, go to Appearance » Widgets. You need to click the plus + icon at the top of the screen to add a new widget, and then search the list for ‘Last Viewed Posts’. After that, simply drag the ‘Last Viewed Posts Redo’ widget to your sidebar.

Add the Last Viewed Posts Redo Widget

Once you click the ‘Update’ button at the top of the screen, you can visit your website to see the list of last visited posts. These will only be visible if you have viewed posts on your blog after installing the plugin.

Preview of Last Viewed Posts

Disclosing That the Plugin Uses Cookies

The Last Viewed Posts plugin does not store the list of recently viewed posts for each user on your website. Instead, the list of posts is saved in each visitor’s web browser so it won’t affect the performance of your website.

Because the plugin uses cookies, you may need to obtain user consent in order to comply with the GDPR. You can learn how to do that by following our guide on how to add a cookies popup in WordPress for GDPR/CCPA.

If a user decides not to allow cookies from your blog, then the list of last visited posts will not be displayed.

We hope this tutorial helped you learn how to display last visited posts to a user in WordPress. You may also want to learn how to create an email newsletter the right way, or check out our list of must have plugins to grow your site.

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

16 CommentsLeave a Reply

  1. Is there a way to do this to have it highlighted next to the post title rather than in a widget?

  2. This is a fantastic little gem. Is there a way to make this display other (custom) post types, or history across a multisite network?

  3. Is there a way to show the whole post (i.e. get_post) instead of just the title? Would you be able to provide the code and the location or where to place it in the plugin code? Thanks!

  4. I have installed the plugin but have trouble installing the widget. Go to Appearance > Widgets > Click on Last Viewed Posts> Click Primary Sidebar>Add Widget, nothing happens. If I drag and drop the Last Viewed Posts still nothing happens.

    Any idea what I’m doing wrong?

    Tony

  5. This works nicely on my localhost but throws a “Cannot modify header information – headers already sent” error on the production server. Seems like content has already begun to output when you set the cookie.

    I’m using Roots theme and WordPress 3.6. Any suggestions on how to solve this?

  6. Hi this plugin is great i have a questions

    can you add a image ( featured image )
    thanks

  7. Thank you for this lovely little plug-in. It greatly adds to the personalization experience on a site.

    David.

  8. Wouldn’t it be better to use some kind of override in your own theme or plugin to change the value of those variables? If you edit the plugin directly, when you update the plugin(which you should always do!) you’ll lose those changes. It shouldn’t be too hard to hook in right after the plugin is activated and assign new values to what I’m assuming are global variables.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.