I would try the following (not tested)
<?php
$friends = get_users( array( 'role' => 'friends' ) );
$friend_ids = array();
foreach( $friends as $friend )
$friend_ids[] = $friend->ID;
$news = new WP_Query( array( 'author' => implode( ',', $friend_ids ), 'post_type' => 'news', 'paged' => get_query_var('paged') ) );
?>
Note: ‘friends’ is the role ID, not the nice name. Then use the loop as normal :
<?php if ( $news->have_posts() ) : while ( $news->have_posts() ) : $news->the_post(); ?>
...
<?php endwhile; endif; ?>
<?php wp_reset_postdata(); ?>
Hopefully that will work 🙂
Related Posts:
- User roles – enable custom posts disable posts
- How to restrict specific post types from being read or added by specific user roles (eg. author)?
- Roles for Custom Post Types
- Hiding posts by other users and non-logged in
- Users create/join groups
- Disable user from updating certain posts
- Create custom post with custom user rules
- Custom User role not working with custom post type
- how to associate several authors to a custom post type
- Preventing role reading others posts
- Clone wp-admin/users.php (Users Admin Page)
- Allow viewing the edit screen for a post type, but not make/save/publish/update changes
- Control what custom posts a user can see
- Display and Allow users to edit their own profiles
- Custom post type role permissions won’t let me read
- Showing User’s Post Counts by Custom Post Type in the Admin’s User List?
- Restrict Contributors to view only their own custom post types?
- Custom user role cannot see or modify featured image
- Custom post type support for get_users(‘orderby=post_count’);
- Allow user to Edit Posts but not Add New?
- Restrict custom post type view by user role
- Confusion with adding meta capabilities to a role after registering a Custom Post Type with corresponding ‘capability_type’ parameter
- Front end registration/login & publish/update 1 custom post
- Associating an “author” with a custom taxonomy
- How to not allow custom roles to edit published custom post types?
- How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?
- Assigning a role to a specific custom post type (and ignoring other post types)
- How to show custom post type count in the users admin page
- grant a privilege for roles (for example editors) and higher
- Prevent author role from editing all posts in custom post type?
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Custom Role can’t trash Custom Post Type
- Community and User Generated Content Website: Have been thinking about Drupal but leaning on WordPress heavily
- Delete Current Author Frontend user while delete custom post type
- Prevent authors from creating new posts of specific custom-post-type
- Registration and Custom Post Types – How to synchronize information?
- WP-Admin edit.php & post.php slowdown after import of 10k users
- using add_role function to make some users to create a selected type post
- Link users to a custom post type
- Cannot attach media when capabilities added to custom post type
- After adding add_role to functions.php and creating a user, can not login into admin
- Ajax Check Post Status
- Want to Add Custom Fields for Uploading video to WordPress Users from front end
- how to delete all users and posts based on ‘user_meta’?
- Role capability delete multiple post type posts doesn’t work
- How to allow a custom user role to create, edit, delete a specific custom post type only?
- Is using taxonomies the way to go here or would custom post types be better?
- Define new user capability for custom post types?
- Only view/edit/delete CPT made by users with the same role
- WordPress comments_open for specific user role or post type
- Restrict Access to Posts based on Custom User and Post Meta Data
- Edit the author of custom post type
- Access to CPT but not to ‘post’ post type
- Allow add new post access to custom post but not wp post for some role
- Allow user to only access custom post type
- How to assign permissions for a CPT to a user
- Want to be able to sign up subscribers as authors
- disable quickedit for specific custom post type user role
- Role capabilities issue
- Query within a foreach within a query (queryception)
- Unable to edit categories in custom post type
- Showing User’s Post Counts by Custom Post Type in the Author.php?
- Prevent user from editing others posts
- Order users by number of posts (includes custom post type)
- Roles and Capabilities in Custom Post Types
- How do I “trash” a custom post type post while logged in as Admin
- How to fix the Post Preview Button (CPT & map_meta_cap)
- Restrict Custom Post Type per role in Dashboard
- Restrict access to custom post type based on its taxonomy terms
- users post count
- While creating a post, can I restrict the authors in the dropdown list based on their user role?
- Link custom post type to users membership
- Show all post type posts in manage users posts column
- Limit 1 post by user in each custom post type
- Assign a Post to a User
- Front-end submitted post is published with admin ID as author
- Add WordPress users to a custom post type
- Custom Post Type Query by user id
- WooThemes – Vendors / Bookings – Allow Vendors to manage resources
- How do you make a custom post type invisible for subscribers
- How can I remove “Add new” button on custom post type
- connect users to Custom post types
- Capabilities and mapping required for a role to be able to edit other’s posts of a custom type, BUT only be able to edit their own blog posts
- Custom user roles
- Custom Post Hierarchy and users
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Weird capabilities / roles behavior
- Add role privileges of the custom post type
- Associate custom categories to different user IDs
- creating different edit screens for different roles
- CPT, Custom User Role and problem with user manager
- Custom post type media upload error with custom user role
- Custom Post Type supports author
- Capability to read user’s own draft post of CPT
- Check in function on custom page
- Reservations as Post
- Custom post type & role issues
- WordPress and Unity high scores table
- empty dashboard for custom role
- WordPress Roles