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?
- How to debug a plugin with Xdebug?
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- Make Categories and Tags required in admin
- Getting wrong relationship value in $args in wp_Query?
- wp_schedule_event in a class
- How to extend LINK TO functionality in ATTACHMENT DISPLAY SETTINGS
- How do I Make a Theme “plugin-ready”?
- How to iterate through custom posts and add the title to an array
- How to Structure a New Role/Capability Scheme?
- How to create Image gallery Metabox in wordpress [closed]
- Is it possible to create an action hook using do_action() within add_action()?
- Custom user profile, registration, login page with theme
- Plugin Sidebar is not Saving Meta Attribute to Post/Page after “Update”
- Possible to preset a widget’s contents via a plugin script?
- Need specific kind of “Poll Voting” for WordPress [closed]
- Install widget on plugin activation
- Plugin admin page meta_box toggle and order state not saving
- Is there a better way to implement responsive images than what WordPress uses by default?
- Prevent Javascript Facebook SDK Conflicts in plugin
- Integrating Stripe PHP library into a custom WordPress Plugin
- How to change the URL pattern for single post view
- What for the tables ending with the meta used in database of wordpress?
- Ensure function has completed before allowing another Ajax call
- Loading scripts with wp_register_script and wp_enqueue_script
- Change the ‘published on’ text?
- WordPress is automatically linking plain text email addresses
- Plugin development – How to use a specific wp_options into the real rendered code in the front end?
- Why is the temporary upload always 4.1K
- Gravity Forms Perks – Nested Forms
- Remove custom post type slug from URL and add taxonomy Slug
- How do I get the sub categories of the parent when in a sub category?
- How to exit a plugin’s execution mid-stream?
- Issue with contextual help overwriting existing content
- Inserting code to HTML view from a pop up initiated from visual view
- Redeclaring a plugin function within a class
- Using a custom shortcode from within the template of a shortcode plugin
- enqueue script/style plungin development
- Trying to get class to instantiate ONCE (or, “why do I keep punching myself in the head?”)
- How to Add a Custom Size for Thumbnails for WP – Gallery
- Will I get an error if I try unscheduling a WP Cron scheduled task that wasn’t scheduled?
- Conditional Generation of Image Sizes using add_image_size
- Plugins and caching
- Display time difference (6 hours ago) in a Soliloquy caption
- Empty Array is Giving Warning for array_merge()
- Is it possible to have instead mypage.com/?page_id=81 to have mypage.com/cool/?
- User Data Handling between two plugins
- Translations only load from `wp-content/languages/plugins` but not from the plugin’s languages folder
- GET request return value as error instead of success
- How to update global variables in plugin activation callback?
- How to include a page template and template part into my plugin
- Multiple instances of $opt_name in redux framework
- The Events Calendar featured image as body background?
- Pass javascript result to shortcode executer function
- Plugins and how to assign urls to content
- problem with blank page
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- first_name property missing inside register_user action hook
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Build a dynamic block using the default attributes
- Bulk post approval and publishing doesn’t work
- Show Admin Menu
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor
- register_activation_hook doesn’t execute without add_action(‘init’,’some-function’)