In our intranet we have 120 locations => 120 groups => 120 Categories and 120 authors. in the home page we want to display a carousel, where we will show post's titles (with link) according to the group For example, the group1 will see a carousel with articles from category1, group2 will see a carousel with articles from category2 .... Of course, authors will continue to feed their categories, how will stored in the carousel by date

Any idea about who can I do that ? Thank you

  • Welcome to WPSE. What kind of content locations and groups are? Are they custom post types, custom taxonomies? Is group a custom user role? Authors are presumably users with Author role, right? May 19 '20 at 19:18
  • Thank you for your response/questions - We want to create a Category per city (eg: News NY, News Miami, ...), we have an author per city, for users they are dispatched on roles (NY_users, Miami_users,...) but all of them are subscribers - please tell me if you need more details
    – Webilix
    May 19 '20 at 20:36

One option could be to have some kind of lookup table, either hard coded or as a settings page, where you map role (user group) to category (city). Then use the current user object to get city based role and use it as a key to get a category ID from the lookup table, which you use in your post query.

Pseudo-code example,

// Current user data
$current_user = wp_get_current_user();
// Get city role
$city_based_role = some_function_to_get_city_role_from_roles($current_user->roles);
// Get category id
$city_category = some_function_to_get_category_id_from_role_to_category_lookup_table($city_based_role);
// Query posts for category
$args = array(
  // some args
  'cat' => $city_category,
$query = new WP_Query($args);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.