The same way you would do it on the frontend, with pre_get_posts
. Combine it with get_current_screen()
so you can tell which area of the admin you’re in, and hook the filter on admin_init
so it doesn’t impact the frontend.
There’s also the restrict_manage_posts
which will let you add inputs to the filter column:
https://developer.wordpress.org/reference/hooks/restrict_manage_posts/
Just note, that WP_Query
can query for posts, and it can restrict by users, but not by role. You will need to fetch an array of the IDs of all the users in that role, then pass it to the query object via pre_get_posts
to specify you only want posts that have those authors in that array of user IDs
Related Posts:
- How to add an admin notice upon post save/update
- Passing current cookies in wp_remote_get to get Draft Post Preview
- Listen to Post action
- Manipulate post category after time
- WooCommerce – Create Products Programatically [closed]
- which action to hook to in order to perform post-publish action
- Cannot access current post’s ID in custom plugin
- Set number of article per number of page
- How to change post status from publish to draft using hook in wordpress?
- prevent showing posts of an specific category in admin posts section
- Using radio button meta data from a custom meta box
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Global $post not working in OOP function WordPress
- Define a wordpress constant through plugin functions?
- How to get post bulk edit action trigger and get edited post ids?
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Prevent Delete Attachment by URL or When Submit
- What hook do you use to update a post?
- Updating post data on save (save_post vs wp_insert_post_data)
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- why str_replace targeting pages instead just targeting post?
- Get author posts count after excluding a category
- Stop post submission without losing data?
- Cant’ Grab WordPress Built-in Posts Through Loop
- How can my plugin display a populated new post window
- search content of pages and list in wp-admin
- Finding a post’s slug
- Insert specific information to a posts of a predefined category
- Open a wordpress single post in a lightbox without the header and footer
- WordPress: Develop multiple posts with different data
- How do I change the post title’s link on the posts page?
- Update user meta when post published no working
- Fixing the WP Post Object for Custom Route
- Export Posts with specific custom fields by sql
- Custom plugin to get related posts by category
- Hide the contents for specific post
- Error 404 blog/page/2/
- Onclick open posts displayed in slider in a popup [closed]
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- Stop WordPress automatically adding tags to post content
- How to prevent posts from being published too close to each other?
- Let private posts stay in status “private” after edit through “editors”
- Change the Slug of Post Type post to baseurl/post/%postname%
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Display most recent post in category instead of archive?
- How do I programmatically add an image to a post?
- problem to delete page
- Display the latest posts, published in the last hour, with WP_Query
- Get user’s most published categories
- Allowing the SoundCloud player to appear in a post excerpt
- Run a function when post is deleted?
- Server-side sorting of posts
- Exclude posts w/ specific post_meta on Rest API endpoint
- Add icon/badge next to posttitle of specific category
- How to change wordpress dates to native language (even if the languge not available i wordpress)
- delete_post hook – deleting multiple items
- How do I exclude the current post from listing in recent posts
- WP_Query orderby not working with meta_value_num and menu_order
- Custom Post Archive Page not working
- Wrong post title displayed from loop
- Custom post types related to same custom post type?
- Disable WordPress Archive Conflict Check
- How To capitalize The First Letter Of Every Word In The Post Title
- Show post content and title in diferent divs using WP_Query using a loop
- Page and post loop same template
- Check if a custom post type has already been created
- how can i display my posts alphabetically?
- Reinstall WordPress while keeping attachments
- How to update all posts at once?
- WordPress Loop: How to display recent posts in multiple divs
- Random posts that always include a particular post?
- Show number of posts by logged in user
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Add Text Domain To Post Navigation
- What would causes search to return incorrect results?
- How to implement a WordPress comments function?
- WordPress – When visiting a `single post/ single.php` my category menu item link becomes active
- How can I restore posts from ‘trash’ with their previous post_status? – WordPress
- Pagination not give another posts
- Shortcode for Comments and Comment Boxes in Post Loop
- Weird problem occurs while using WordPress REST API to create new post
- Centre Blog Index (Posts Page) on Home.php
- Dropdown Select Post Filter
- Add postmeta to all blog posts
- Code to display random ordered posts in Categories across pages [duplicate]
- How to give priority to page than to posts permalink structure?
- Add category information beneath post?
- how to remove entry meta from wordpress archive category and change its display
- Save/retrieve form data best practises for theme development
- Removing standard links in the posts page
- How to handle a post before publishing?
- Changing permalink of custom category
- Error establishing a database connection
- How to limit the number of posts a user can publish based on user type
- Single post pagination
- posts_per_page – Repeats only first posts ‘post__in’ array
- Undefined Function Fatal Error with Shortcode [closed]
- I have a website issue I am trying to resolve
- How to sort posts alphabetically based on a specific parent category