We’re creating a site where we want guest users to add pages to a favourites list (post IDs), so they can print or email their selection if they want.
What would the best way be to do this in WordPress? I think ajax but I’m not too sure how to save it in the WordPress framework.
Cookies, or even HTML5 local storage, seem like a good way to implement this. Here’s some basic code that could serve as a starting point. Post IDs are stored as CSV in the cookie.
You can save the information directly to a database table, so you’d have a table of userIDs associated with postIDs, and to get the list of posts that user has favorited, you can run a query on the database.
See: Class Reference/wpdb