Correct Post Count ( All | Published | Drafts | Pending | Trash ) for Custom Post Type when restricting to view own posts

You have to change: ‘post_type’ => ‘post’, To: ‘post_type’ => ‘your_custom_post_type_name’, And a all the reference to standard post. Also, you should add the filters only for main query or you can end up with issues in secondary queries. Bellow an example code for gallery custom post type. I was trying to debug the code … Read more

How to restrict attachment download to a specific user?

What needs to happen is that you need to proxy download requests for the file types you want through WordPress. Let’s assume you’re going to restrict access to “.doc” files. 1. Define a query variable that indicates the requested file function add_get_file_query_var( $vars ) { $vars[] = ‘get_file’; return $vars; } add_filter( ‘query_vars’, ‘add_get_file_query_var’ ); … Read more