
add_action('views_edit-post','remove_edit_post_views');function remove_edit_post_views( $views ){
$views['pre']='<a href="'.admin_url().'edit.php?pre=pre">My Special Posts</a>';return $views;}
add_action('pre_get_posts','my_special_list');function my_special_list( $q ){
$scr = get_current_screen();if( is_admin()&&( $scr->base==='edit')&& $q->is_main_query()){// To target only a post type uncomment following line and adjust post type name// if ( $scr->post_type !== 'post' ) return;// if you change the link in function above adjust next line accordingly
$pre = filter_input(INPUT_GET,'pre', FILTER_SANITIZE_STRING);if( $pre ==='pre'){// adjust meta query to fit your needs
$meta_query = array('key'=>'is_special','value'=>'yes',);
$q->set('meta_query', array($meta_query));}}}
Leave a Reply
Want to join the discussion?Feel free to contribute!