I have a lot of video posts on my site and I’m looking to show the user a list of posts they’ve recently viewed. I’m guessing the best route is to just add the post id to an array in their usermeta when they visit a post but I’m wondering how can I do that and still be able to show them a chronological order of posts in which they viewed them. And also I wanna clip the number of posts in the array keeping it at 20 posts or so that the array isn’t out of control. Any ideas?
Leave a Reply
You must be logged in to post a comment.
This plugin may fulfill your requirements.
Usage
get_recently_viewed_posts( $max_shown = 10 )
returns a string of li’s.recently_viewed_posts( $max_shown = 10 )
prints a divIf you are interested in learning how to develop this functionality yourself, download the plugin and see the source files. WordPress is Open Source!
Update:
The above plugin did not work. The following approach will help to
get the recently viewed video ids.
do action()
in your template to see the change of array values (video ids) while you are browsing through the posts.do_action('wpse_63266_recently_viewed');