How allow users to save list of posts?

I am not asking you to write the all code or asking a plugin, I am asking a way to build this feature because I don’t have any plan in my mind to build this feature.

This is the requirement : There are many posts on the website. Logged Users (Front-end users) should have a feature to save list of posts.

Ex :

  • List 01 : My favorite Posts
  • List 02 : Blogging related posts
  • List 03 : Watch later Posts

I want user to allow to create these types of list. Then they can add any number of posts. And these list are private. I mean only created user can access the list.

This is something like we label emails on gmail.

What can I use to save list? I have no idea what can I use for it… At least is this possible with WordPress?

3 Answers
3

When I am thinking about UI something like this is comming to my mind.

enter image description here

Something similar has YouTube under the video.

When user fills input and clicks enter or submit button to create list, you will send ajax request with list name and save it as a record in wp_usermeta table with meta_key _list_user_1 and meta_value as list title.

To add post to this list you have to save record in wp_postmeta table with _list_post_1 value in meta_key field and value of umeta_id from _list_user_1 row in field meta_value.

wp_usermeta

+----------+---------+--------------+------------+
| umeta_id | user_id | meta_key     | meta_value |
+----------+---------+--------------+------------+
| 100      | 1       | _list_user_1 | List 1     |
+----------+---------+--------------+------------+

wp_postmeta

+---------+---------+--------------+------------+
| meta_id | post_id | meta_key     | meta_value |
+---------+---------+--------------+------------+
| 1       | 1       | _list_post_1 | 100        |
+---------+---------+--------------+------------+

To get all lists for user:

SELECT *
FROM `wp_usermeta`
WHERE `user_id` = 1
  AND `meta_key` LIKE "_list_user_%";

To get all posts for List 1:

SELECT *
FROM `wp_posts`
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
WHERE wp_postmeta.`meta_key` LIKE "_list_post_%"
  AND wp_postmeta.`meta_value` = 100;

Leave a Comment