How are you associating users to a post?
If you meant users as post authors you can try pre_get_posts
hook.
function user_author_pre_get_posts( $query ) {
$user_id = get_current_user_id(); // Get logged in user ID or pass specific user ID here
if ( ( $query->is_author() || $query->is_category() ) && $query->is_main_query() ) {
$query->set( 'author__in', $user_id );
}
}
add_action( 'pre_get_posts', 'user_author_pre_get_posts' );
Related Posts:
- How to show related posts by category
- Display all posts from specific categories on a page
- Query only Posts from Both of Two Category?
- Featured Posts for Category Pages
- Get user’s most published categories
- Category Foreach keeps looping?
- How to make multiple sections in home pulling posts category wise?
- All categories displays the same posts
- WordPress displays post on subcategory only
- How to get posts ordered by using their categories?
- Getting posts from some categories plus some individual posts
- Is there a way to save different data when USER interacts with the same POST?
- Querying posts from current category, using a variable as array argument
- Add new post only in assigned category
- Need help writing loop to display posts by categories in separate divs
- Query post category & remove any post id
- How to pass multiple checkbox values to wordpress query?
- Delete old post with new post
- each user having category with their name and can add sub categories post in that category
- Change from all posts to specific categories post on main page?
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Automatically select category based on user role
- How to show related posts by detecting the current category?
- Display posts on a custom page from only a specific category?
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- Order posts alphabetically: how to set order=asc in mysql query?
- How to order posts in an arbitrary order?
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- How do I manage my users post before publish?
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- Display Posts on Custom Page
- How to get posts from a current post’s month?
- How do I retrieve a users’ last 5 posts?
- Gather posts into a cart/lightbox and share with another user
- Hide posts belongs to few categories in homepage
- Wrong post title displayed from loop
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- why does wordpress ignore the post args?
- While loop articles – if statement order
- post category in wp_insert_post
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- Conditionals if tags exist?
- query_post order desc
- How to get subcategories from category slug?
- Remove current category from post but display all others
- How show categories in admin and get that selected to show posts in index
- WordPress website loads more posts than expected
- Showing categories and subcategories with posts
- Change default category when I publish a post
- Get the amount of posts on a current page
- store posts_id of category into a varable?
- Posts – display all posts except a post by an ID
- Assign published posts to another user automatically
- Counter is skipping post when I still want it visible [closed]
- How to display two random-post sections that are each under their own category
- How can you display all sibling categories to a post?
- Loop doesn’t exclude the specified category in home page
- query post limits
- Display posts of specific category term
- Add field to user meta table in database when link is clicked
- Widget that shows categories with posts numbers
- How to create a sub post?
- Hide comments and posts posted by other user
- Post Image not displaying in category view
- Automatically create a default set of posts for each new registered user
- why the same code got different results when using query_posts in functions.php and index.php
- Display Posts with template on a Page
- How do I show posts from another wordpress installation?
- Query for first 3 posts to change the look and feel
- Archive template combined with post slider and regular posts
- How to get posts published on the latest date?
- get posts from Custom Post Type & Category
- Category page when using static front page
- Latest posts by category — how to exclude current post?
- How to only publish posts with image in it
- How do I include the category next to the title of a post?
- Relative number of post in category
- How to create a “latest news” page showing a list of posts from blog category
- Summary of Posts by an User
- WordPress bulk category select when publishing post
- Exclude some categories from listing on the current post
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- How to check in functions.php if there is data in a WP_Query?
- Shortcode with ‘year’ parameter
- how to hide empty fields of post category description?
- Display a list of users who have viewed the post you are viewing
- how can i display my posts alphabetically?
- Post Filtering by GET URL parameters
- if in category but only with post meta
- How to get post with associated categories and tags names instead of ids with rest api?
- On what hook can I get the queried object’s final state?
- Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
- Display a mixed list of posts and media