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
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
Share Improve this question asked May 19, 2020 at 14:33 WebilixWebilix 1 2- 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? – Antti Koskinen Commented May 19, 2020 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 Commented May 19, 2020 at 20:36
1 Answer
Reset to default 0One 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);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742403530a4437383.html
评论列表(0条)