All Topics
Post__in array of IDs on edit screen?
Hi
Is it possible to have something like /wp-admin/edit?my_post_ids=100,200,300,400 where the edit screen just shows those 4 posts
I’ve tried a solution on stack exchange for the regular wordpress screen, but haven’t been able to get it to work with Admin Columns Pro?
/**
* Usage:
* http://example.com/wp-admin/edit.php?my_post_ids=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_post_ids'] ) )
return $query;
// Finally, filter
$limit_posts = explode( ',', $_GET['my_post_ids'] ); // Convert comma delimited to array
$query->set( 'post__in', $limit_posts );
return $query;
}
Essentially I’d like to be able to access one url with a list of post IDs, and just show those posts on the edit screen? Thanks in advance.
You must be logged in to reply to this topic.