At first you need to set a meta value when a post is visited using this way
if( is_user_logged_in() ) {
update_post_meta( $post_id, 'post_readed_by', get_current_user_id() );
}
Then you can get the recent visited posts
<?php
$args = array(
'posts_per_page' => 10,
'meta_key' => 'post_readed_by',
'meta_value' => get_current_user_id(),
'post_type' => 'post',
'post_status' => 'publish',
);
$posts_array = get_posts( $args ); ?>
You can use the $posts_array variable this way
foreach ( $posts_array as $post ) : setup_postdata( $post );
the_title();
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
the_content();
endforeach;
wp_reset_postdata();
Hope you understand how to manipulate these
Related Posts:
- If the current user is an administrator or editor
- How do I add a field on the Users profile? For example, country, age etc
- user_login vs. user_nicename
- WordPress usermeta scaling for thousands of users
- Groups of capabilities: users with multiple roles?
- Is there a way to merge two users?
- How to restrict access to uploaded files?
- Best way to send users password?
- Why are user address fields required [closed]
- Allow guests to save favourite pages?
- Basic auth WordPress REST API dilemma
- Remove all users from site except one using WP CLI
- security+best practices: root or www-data on a wordpress content folder?
- Show Biographical Info while creating new user
- importing users where password is provided as md5 + much metadata
- User File Upload Repository?
- How to get user ID during registration and add it to a custom table
- How do I properly format the user_role array?
- How can I secure a WordPress blog using OpenID from a single provider?
- How to edit user_id on the comment edit screen
- Redirect after login based on user role (custom login page)
- get_users() ORDER BY Not Working
- Can I create users that have access to *some* other users posts instead of all other users posts?
- My custom page template with is_user_logged_in() does not detect that I’m logged in
- Total Word Count For Posts And Comments By One Author
- Delete user from frontend
- Tagging users in WordPress
- Share user table from WP with Drupal
- How can I display show/hide elements when user is registered?
- WordPress User getting added with id of 0
- Log all users out of all locations after 24 hours
- Force logout ALL users at a certain time
- Show MD5 Password in user section
- RSS feed for a given user’s post?
- add_cap not working with Shop Manager role
- Plugin for limiting user registration based on ip with expiry period?
- Bulk delete users from a csv list
- Get tags for current user
- how to update or refresh the wp user object?
- Users managed to register on website with no register button?
- Is there a way to make custom fields only editable by administrators?
- How to use WordPress for class notes?
- Including users in insert link internal link search in Gutenberg
- How to Check User type from the form user registers in user_register hook?
- Add value in user table when user is created
- How to hide WordPress users’ names externally?
- Editable registration date field in user profile
- How to force authors to ‘submit for review’?
- How do I transfer user passwords from one WordPress site to another?
- How can I authenticate user credentials against a WordPress instance?
- Add a role and give admin priviledges
- WordPress registration without wp-login.php and wp-admin folder, is it possible?
- List users by meta_key and meta_value
- MySQL query to mass change role of users
- How to get last user with wpdb?
- How to Create a User Profile Page?
- List Users alphabetically with heading
- How to default/force the user’s display_name to their nickname?
- Restrict access to non-wordpress section of site with user roles?
- how to remove email field from default user registration form on wordpress
- How can I change “Users” related labels in the wordpress dashboard
- Does it matter if the very first user, usually Admin, does not have a user ID of 1?
- How to set default’ => $current_user->user_login
- Groups and subgroups for permission
- User can manage one page accessible by everyone?
- How to add an attribute to a user?
- Can i use two different user tables for on WP install?
- SELECT from wp_users, get Displayname too
- Redirect current user to their most recent custom post
- how redirect users to custom login page when “login to reply” is clicked? [duplicate]
- Making WordPress available while logged into another website
- Get user ID when action row link is clicked
- Advanced Custom Fields Plugin: how would I get an image src path uploaded from User Profile?
- Whenever I got to my new pages (http://www.cwmags.com/news) it requests login?
- how to delete in phpmyadmin sql – all users with certain condition and all dependencies
- Author Error “Sorry, you are not allowed to access this page.”
- How to give guest users “not logged in” a role?
- How to Moderate Edits to User Profiles?
- Front-end uploader logging user out when they attempt to upload image
- Upon running wp_insert_user() WP Keeps Saying user_login is already in the system when it isn’t
- wp_insert_user always tries the same user name
- Limit a user only to wp-cli only use
- What is the best user experience for user to perform an action using email?
- Registration page as homepage
- How to add karma points to users?
- WordPress install checking permissions of user id 0
- How to do a search based on the user’s location & search term and return proximity-based results?
- Store extra user values permanently
- New User ID not working in custom function with user_register hook
- Registered access area
- Error when send reset password
- How to disable users changing their display_name?
- Are there any hook or filter when adding new user in WordPress?
- Creating Custom user type just like custom post
- Control Category of each user can post
- Have users created automatically when a network site is created
- How-To: Get meta data from the users last order in woocommerce
- How to allow users to make quizzes or tests in WordPress?
- Sorting Users page admin column with ACF field
- Can we get user profile page using user_id in the URL?