I almost found out how to deal with the problem. I’ve written this function:
function myfilter($query) {
if (isset($_GET[‘post_type’]) && post_type_exists($_GET[‘post_type’]) && in_array(strtolower($_GET[‘post_type’]), array(‘dx_invoice’, ‘here’))) {
if(!is_admin() ) {
global $user_ID;
$query->set(‘author’, $user_ID);
}
}
return $query;
}
add_filter(‘pre_get_posts’, array( $this, ‘myfilter’));
Now the only problem is whenever I browse the CPT listing (edit.php?post=my_cpt) I can see three links: Mine | All | Published, the page defaults to “Mine”, but All and Published are still accessible, any idea how to prevent that?