It can be achieved using pre_get_posts
.
It is important to prefix all your variable names, id
seems not be in the reserved terms list, but anyway this practice avoids any unforeseen bug.
/**
* Usage:
* http://example.com/wp-admin/edit.php?my_pids=4088,4090,4092,4094
*/
add_filter( 'pre_get_posts', 'limit_post_list_wpse_96418' );
function limit_post_list_wpse_96418( $query )
{
// Don't run on frontend
if( !is_admin() )
return $query;
global $pagenow;
// Restrict to Edit page
if( 'edit.php' !== $pagenow )
return $query;
// Check for our filter
if( !isset( $_GET['my_pids'] ) )
return $query;
// Finally, filter
$limit_posts = explode( ',', $_GET['my_pids'] ); // Convert comma delimited to array
$query->set( 'post__in', $limit_posts );
return $query;
}
Related Posts:
- Plugin API for easy admin list table generation, handling & exporting of MySQL tables?
- How are bulk actions handled in custom list table classes?
- How do I create links at the top of WP_List_table?
- Using query_vars filter
- How-to implement admin Ajax inside an admin WP_List_Table?
- Create a clickable name in WP_List_Table for Plugin Admin
- Extending WP_List_Table seems getting wrong with $this->get_columns() – what’s wrong?
- Get a custom table to an array
- How to display additional info in the plugins admin table?
- how to make custom bulk actions for a WP_List_Table (core class)
- Problems with: manage_${post_type}_posts_columns
- $paged always 0 on plugin’s custom page
- How to show filters on table when using WP_List_Table
- Wp_list_table search box not working for custom value from database
- WordPress pre_get_posts with combined results of two queries (OR)
- wp_get_post_terms Order by not working
- Prevent WordPress automatically processing certain URL queries
- Why in this archive page that call query_posts() function show only the last 10 posts?
- insert query on a custom table using ajax with jQuery plugin Jeditable
- Taxonomy archive page listing terms instead of posts
- Brainstorm – Slow Query from Plugin Need to Speed It Up
- Checking for existing title in custom db query not working
- Load specific page when a custom URL is hit
- WP_List_Table Inside Metabox With Bulk Actions Not Working on Submit
- How to grab data after wp user search is complete
- WP_Query not ordering correctly
- Wp_List_Table is showing as no class found named wp list table
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- bindParam? WordPress 4.9.5 SQL LIKE statement %s and %LIKE%
- Different style for specific rows in custom list table using WP_List_Table
- WP Query Relations / Compare
- Array/List Edit in Backend
- Add query string variables to all hyperlinks URL matching a specified domain
- Extend WP_List_Table class – Edit wp_usermeta – WPPB.me Boilerplate – Action error
- Checking if the query is empty does not work
- Can I log the searches that are returning 404 in the DB?
- WP_List_Table sortable column with WC_Order_Query doesn’t work
- Objective Best Practices for Plugin Development? [closed]
- add_menu_page() with different name for first submenu item
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- A tool to analyze rewrite rules? [closed]
- Difference Between Filter and Action Hooks?
- framework for plugin/theme options panel? [closed]
- Creating a table in the admin-style?
- How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?
- Settings API with arrays example
- How to get the path to the current theme?
- How to make a plugin require another plugin?
- ajaxurl not defined on front end
- What process do you use for WordPress development? [closed]
- What’s the difference between term_id and term_taxonomy_id
- Should I use wpdb prepare?
- Why does WordPress use outdated jQuery v1.12.4?
- Post meta vs separate database tables
- Is there any plugin development framework
- Is it possible to reuse wp.media.editor Modal for dialogs other than media
- How to add a javascript snippet to the footer that requires jQuery
- Enhance Media Manager for Gallery
- How do I create a custom role capability?
- How do I add CSS options to my plugin without using inline styles?
- How do i best handle custom plugin page actions?
- Adding Custom Text Patterns in the WP 4.5 Visual Editor
- Automatically determine minimum WordPress version required for a plugin?
- What is the advantage of using wp_mail?
- How to make a WordPress plugin translation ready?
- How many times will this code run? (or, how rich is grandma?)
- How to create an API for my plugin?
- Is it ever okay to include inline CSS in plugins?
- Plugins in symlinked directories?
- How to override existing plugin action with new action
- How to include a file using get_template_part() in a plugin?
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- body_class hook for admin pages
- “Error: Options Page Not Found” on Settings Page Submission for an OOP Plugin
- Is it mandatory to use $wpdb->prefix in custom tables
- Which hook should be used to add an action containing a redirect?
- add_action hook for completely new post?
- Why does WordPress add 0 (zero) to an Ajax response?
- What should I use instead of WP_CONTENT_DIR and WP_PLUGIN_DIR?
- How to enqueue JavaScripts in a plugin
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Plugin Form Submission Best Practice
- How to redirect to settings page once the plugin is activated?
- Is get_option function cached?
- Should Plugin Folders Include a Blank index.php File?
- Unit testing for plugin development
- Methods of Integrating Plugin Data with Themes
- What is the wordpress wp-includes folder for?
- WordPress Update Plugin Hook/Action? Since 3.9
- How to include jQuery and JavaScript files correctly?
- How come `wp_options` table does not have an index on `autoload`?
- PHP error with shortcode handler from a class
- Update Option Stored in Multi-Dimensional Array
- check if Gutenberg is currently in use
- Best way to abort plugin in case of insufficient PHP version?
- WordPress Plugin Development – Headers Already Sent Message
- WP 3.3 How to Add Menu Items to the Admin Bar?